11. What will be the output of the following Python code?
l=[1, -2, -3, 4, 5]
def f1(x):
return x<2
m1=filter(f1, l)
print(list(m1))
l=[1, -2, -3, 4, 5]
def f1(x):
return x<2
m1=filter(f1, l)
print(list(m1))12. How can you pass a list to a function as an argument?
13. What will be the output of the following Python code?
x = 'abcd'
print(list(map(list, x)))
x = 'abcd'
print(list(map(list, x)))14. How are default arguments specified in the function heading?
15. How are variable length arguments specified in the function heading?
16. Which type of copy is shown in the following python code?
l1=[[10, 20], [30, 40], [50, 60]]
ls=list(l1)
ls
[[10, 20], [30, 40], [50, 60]]
l1=[[10, 20], [30, 40], [50, 60]]
ls=list(l1)
ls
[[10, 20], [30, 40], [50, 60]]17. What will be the output of the following Python code?
odd=lambda x: bool(x%2)
numbers=[n for n in range(10)]
print(numbers)
n=list()
for i in numbers:
if odd(i):
continue
else:
break
odd=lambda x: bool(x%2)
numbers=[n for n in range(10)]
print(numbers)
n=list()
for i in numbers:
if odd(i):
continue
else:
break18. What will be the output of the following Python code?
x = 1234
print(list(map(list, x)))
x = 1234
print(list(map(list, x)))19. What will be the output of the following code:
def multiply(a, *args):
result = a
for num in args:
result *= num
return result
result = multiply(2, 3, 4)
print(result)
def multiply(a, *args):
result = a
for num in args:
result *= num
return result
result = multiply(2, 3, 4)
print(result)20. What happens if a local variable exists with the same name as the global variable you want to access?
Read More Section(Functions in Python)
Each Section contains maximum 100 MCQs question on Functions in Python. To get more questions visit other sections.
