21. What will be the output of the following Python code?
x = [34, 56]
print((''.join(list(map(str, x))),))
x = [34, 56]
print((''.join(list(map(str, x))),))
22. What will be the output of the following Python code?
x = [[0], [1]]
print(len(' '.join(list(map(str, x)))))
x = [[0], [1]]
print(len(' '.join(list(map(str, x)))))
23. 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))))))
24. What will be the output of the following Python code?
l1=[1, 2, 3, [4]]
l2=list(l1)
id(l1)==id(l2)
l1=[1, 2, 3, [4]]
l2=list(l1)
id(l1)==id(l2)
25. What will be the output of the following Python code?
def display(b, n):
while n > 0:
print(b,end="")
n=n-1
display('z',3)
def display(b, n):
while n > 0:
print(b,end="")
n=n-1
display('z',3)
26. What will be the output of the following Python code?
def foo(fname, val):
print(fname(val))
foo(max, [1, 2, 3])
foo(min, [1, 2, 3])
def foo(fname, val):
print(fname(val))
foo(max, [1, 2, 3])
foo(min, [1, 2, 3])
27. What will be the output of the following Python code?
def cube(x):
return x * x * x
x = cube(3)
print x
def cube(x):
return x * x * x
x = cube(3)
print x
28. What is the purpose of a docstring in a function?
29. What will be the output of the following Python code?
def f1():
global x
x+=1
print(x)
x=12
print("x")
def f1():
global x
x+=1
print(x)
x=12
print("x")
30. What will be the output of the following Python code?
l1=[10, 20, 30]
l2=l1
id(l1)==id(l2)
l2=l1.copy()
id(l1)==id(l2)
l1=[10, 20, 30]
l2=l1
id(l1)==id(l2)
l2=l1.copy()
id(l1)==id(l2)
Read More Section(Functions in Python)
Each Section contains maximum 100 MCQs question on Functions in Python. To get more questions visit other sections.