11. What is the primary use of the @staticmethod decorator?
12. What will be the output of the following Python code?
def f(x):
def f1(a, b):
print("hello")
if b==0:
print("NO")
return
return f(a, b)
return f1
@f
def f(a, b):
return a%b
f(4,0)
def f(x):
def f1(a, b):
print("hello")
if b==0:
print("NO")
return
return f(a, b)
return f1
@f
def f(a, b):
return a%b
f(4,0)
13. In Python, what is the purpose of the @classmethod decorator?
14. The following python code can work with . . . . . . . . parameters.
def f(x):
def f1(*args, **kwargs):
print("Examveda")
return x(*args, **kwargs)
return f1
def f(x):
def f1(*args, **kwargs):
print("Examveda")
return x(*args, **kwargs)
return f1
15. What will be the output of the following two codes?
i. '{0}'.format(4.56)
ii. '{0}'.format([4.56,])
i. '{0}'.format(4.56)
ii. '{0}'.format([4.56,])
16. In Python, what is the purpose of the locals() function?
17. What will be the output of the following Python expression if X=345?
print(“%06d”%X)
print(“%06d”%X)
18. What will be the output of the following Python code?
l=list('HELLO')
p=l[0], l[-1], l[1:3]
'a={0}, b={1}, c={2}'.format(*p)
l=list('HELLO')
p=l[0], l[-1], l[1:3]
'a={0}, b={1}, c={2}'.format(*p)
19. What will be the output of the following Python code?
def mk(x):
def mk1():
print("Decorated")
x()
return mk1
def mk2():
print("Ordinary")
p = mk(mk2)
p()
def mk(x):
def mk1():
print("Decorated")
x()
return mk1
def mk2():
print("Ordinary")
p = mk(mk2)
p()
20. What will be the output of the following Python code snippet?
x=3.3456789
'%s' %x, str(x)
x=3.3456789
'%s' %x, str(x)