21. What will be the output of the following Python code?
def d(f):
def n(*args):
return '$' + str(f(*args))
return n
@d
def p(a, t):
return a + a*t
print(p(100,0))
def d(f):
def n(*args):
return '$' + str(f(*args))
return n
@d
def p(a, t):
return a + a*t
print(p(100,0))
22. What will be the output of the following Python expression if the value of x is 34?
print(“%f”%x)
print(“%f”%x)
23. The . . . . . . . . symbol along with the name of the decorator function can be placed above the definition of the function to be decorated works as an alternate way for decorating a function.
24. Which module must be imported to use the @abstractmethod decorator in Python?
25. What is the output of the code: print("{:<10}".format("hello"))?
26. The output of the two codes shown below is the same.
i. '{0:.2f}'.format(1/3.0)
ii. '%.2f'%(1/3.0)
i. '{0:.2f}'.format(1/3.0)
ii. '%.2f'%(1/3.0)
27. What will be the output of the following Python code?
'{0:f}, {1:2f}, {2:05.2f}'.format(1.23456, 1.23456, 1.23456)
'{0:f}, {1:2f}, {2:05.2f}'.format(1.23456, 1.23456, 1.23456)
28. What will be the output of the following Python code?
'{a}, {0}, {abc}'.format(10, a=2.5, abc=[1, 2])
'{a}, {0}, {abc}'.format(10, a=2.5, abc=[1, 2])
29. The formatting method {1:<10} represents the . . . . . . . . positional argument, . . . . . . . . justified in a 10 character wide field.
30. What will be the output of the following Python code?
def c(f):
def inner(*args, **kargs):
inner.co += 1
return f(*args, **kargs)
inner.co = 0
return inner
@c
def fnc():
pass
if __name__ == '__main__':
fnc()
fnc()
fnc()
print(fnc.co)
def c(f):
def inner(*args, **kargs):
inner.co += 1
return f(*args, **kargs)
inner.co = 0
return inner
@c
def fnc():
pass
if __name__ == '__main__':
fnc()
fnc()
fnc()
print(fnc.co)