21. Which of these is false about recursion?
22. What is the purpose of using the * symbol in function argument packing?
23. What is the type of each element in sys.argv?
24. What will be the output of the following Python code?
l=[]
def convert(b):
if(b==0):
return l
dig=b%2
l.append(dig)
convert(b//2)
convert(6)
l.reverse()
for i in l:
print(i,end="")
l=[]
def convert(b):
if(b==0):
return l
dig=b%2
l.append(dig)
convert(b//2)
convert(6)
l.reverse()
for i in l:
print(i,end="")25. What will be the output of the following Python code?
l=[n for n in range(5)]
f=lambda x:bool(x%2)
print(f(3), f(1))
for i in range(len(l)):
if f(l[i]):
del l[i]
print(i)
l=[n for n in range(5)]
f=lambda x:bool(x%2)
print(f(3), f(1))
for i in range(len(l)):
if f(l[i]):
del l[i]
print(i)26. The single line equivalent of the following Python code?
l=[1, 2, 3, 4, 5]
def f1(x):
return x<0
m1=filter(f1, l)
print(list(m1))
l=[1, 2, 3, 4, 5]
def f1(x):
return x<0
m1=filter(f1, l)
print(list(m1))27. What will be the output of the following Python code?
def C2F(c):
return c * 9/5 + 32
print C2F(100)
print C2F(0)
def C2F(c):
return c * 9/5 + 32
print C2F(100)
print C2F(0)28. What will be the output of the following Python code?
def say(message, times = 1):
print(message * times)
say('Hello')
say('World', 5)
def say(message, times = 1):
print(message * times)
say('Hello')
say('World', 5)29. What will be the output of the following Python code?
f=lambda x:bool(x%2)
print(f(20), f(21))
f=lambda x:bool(x%2)
print(f(20), f(21))30. What will be the output of the following Python code?
import functools
l=[1, 2, 3, 4, 5]
m=functools.reduce(lambda x, y:x if x>y else y, l)
print(m)
import functools
l=[1, 2, 3, 4, 5]
m=functools.reduce(lambda x, y:x if x>y else y, l)
print(m)Read More Section(Functions in Python)
Each Section contains maximum 100 MCQs question on Functions in Python. To get more questions visit other sections.
