31. How are keyword arguments specified in the function heading?
32. Fill in the line of the following Python code for calculating the factorial of a number.
def fact(num):
if num == 0:
return 1
else:
return _____________________
def fact(num):
if num == 0:
return 1
else:
return _____________________
33. What will be the output of the following Python code?
def fun(n):
if (n > 100):
return n - 5
return fun(fun(n+11));
print(fun(45))
def fun(n):
if (n > 100):
return n - 5
return fun(fun(n+11));
print(fun(45))
34. What will be the output of the following Python code?
list(map((lambda x:x**2), filter((lambda x:x%2==0), range(10))))
list(map((lambda x:x**2), filter((lambda x:x%2==0), range(10))))
35. What will be the output of the following code:
def my_function(a, b):
return a / b
result = my_function(4, 2)
print(result)
def my_function(a, b):
return a / b
result = my_function(4, 2)
print(result)
36. What will be the output of the following Python code?
a = [1, 2, 3, 4, 5]
b = lambda x: (b (x[1:]) + x[:1] if x else [])
print(b (a))
a = [1, 2, 3, 4, 5]
b = lambda x: (b (x[1:]) + x[:1] if x else [])
print(b (a))
37. Which of the following statements is false about recursion?
38. What will be the output of the following Python code?
x = ['ab', 'cd']
print(len(list(map(list, x))))
x = ['ab', 'cd']
print(len(list(map(list, x))))
39. Which of these is not true about recursion?
40. What will be the output of the following Python code?
list(map((lambda x:x^2), range(10)))
list(map((lambda x:x^2), range(10)))
Read More Section(Functions in Python)
Each Section contains maximum 100 MCQs question on Functions in Python. To get more questions visit other sections.