31. Identify the decorator in the snippet of code shown below.
def sf():
pass
sf = mk(sf)
@f
def sf():
return
def sf():
pass
sf = mk(sf)
@f
def sf():
return
32. Which built-in function is used to check if an object is an instance of a particular class?
33. What is the purpose of the @staticmethod decorator compared to the @classmethod decorator?
34. What will be the output of the following Python code?
l=list('HELLO')
'first={0[0]}, third={0[2]}'.format(l)
l=list('HELLO')
'first={0[0]}, third={0[2]}'.format(l)
35. What will be the output of the following Python code snippet?
x=3.3456789
'%-6.2f | %05.2f | %+06.1f' %(x, x, x)
x=3.3456789
'%-6.2f | %05.2f | %+06.1f' %(x, x, x)
36. The two snippets of the following Python codes are equivalent.
CODE 1
@f
def f1():
print(“Hello”)
CODE 2
def f1():
print(“Hello”)
f1 = f(f1)
CODE 1
@f
def f1():
print(“Hello”)
CODE 2
def f1():
print(“Hello”)
f1 = f(f1)
37. What will be the output of the python code shown below for various styles of format specifiers?
x=1234
res='integers:...%d...%-6d...%06d' %(x, x, x)
res
x=1234
res='integers:...%d...%-6d...%06d' %(x, x, x)
res
38. What will be the output of the following Python code?
t = '%(a)s, %(b)s, %(c)s'
t % dict(a='hello', b='world', c='universe')
t = '%(a)s, %(b)s, %(c)s'
t % dict(a='hello', b='world', c='universe')