31. What will be the output of the following Python code?
def foo(i, x=[]):
x.append(i)
return x
for i in range(3):
print(foo(i))
def foo(i, x=[]):
x.append(i)
return x
for i in range(3):
print(foo(i))32. What does the nonlocal keyword do when used in a function?
33. What will be the output of the following Python code?
def f(x):
print("outer")
def f1(a):
print("inner")
print(a,x)
f(3)
f1(1)
def f(x):
print("outer")
def f1(a):
print("inner")
print(a,x)
f(3)
f1(1)34. What will be the output of the following Python code?
def f1(a,b=[]):
b.append(a)
return b
print(f1(2,[3,4]))
def f1(a,b=[]):
b.append(a)
return b
print(f1(2,[3,4]))35. What will be the output of the following Python code?
x = abcd
print(list(map(list, x)))
x = abcd
print(list(map(list, x)))36. How can you define a function that accepts an arbitrary number of keyword arguments?
37. Which of these is not true about recursion?
38. Which of the following is the use of function in python?
39. What will be the output of the following Python code?
def f1():
x=100
print(x)
x=+1
f1()
def f1():
x=100
print(x)
x=+1
f1()40. What is the output of the following code:
def power(x, n=2):
return x ** n
result = power(3)
print(result)
def power(x, n=2):
return x ** n
result = power(3)
print(result)Read More Section(Functions in Python)
Each Section contains maximum 100 MCQs question on Functions in Python. To get more questions visit other sections.
