MCQs Lambda
1.The general syntax of a lambda function is ________
- lambda argument_list: expression
- lambda argument_list- expression
- lambda(): expression
- none of the above
Ans : lambda argument_list: expression
2.Carefully read the question and answer accordingly. What Is The Output Of The Following Code Snippet? myList = [lambda x: x ** 2, lambda x: x ** 3, lambda x: x ** 4] for f in myList: print(f(3))
- 2781343
- 6,9,12
- 9,27,81
- 8,27,64
Ans : 9,27,81
3. What Is The Output Of The Following Code Snippet?
exp = lambda x ** 3
print(exp(2))
- 6
- 222
- 8
- Error
Ans: Error
4.What Is The Output Of The Following Code Snippet?
exp = lambda x: 3 ** x
print(exp(2))
- Error
- 222
- 9
- 6
Ans : 9
5. What Is The Output Of The Following Code Snippet?
fn=lambda e:e-2
fn(1)
- -2
- 0
- 1
- -1
Ans : -1
6. Carefully read the question and answer accordingly.
What Is The Output Of The Following Code Snippet?
print((lambda e:e-2)(1))
- 1
- 0
- -1
- Error
Ans : -1
7.Carefully read the question and answer accordingly.
Predict the Output?
o=lambda x=1,y=2,z=3:x+y+z
print(o(2))
- 8
- 7
- 5
- 6
Ans: 7
8.Carefully read the question and answer accordingly.
State True or False:
Python lambda expressions may take arguments, and takes one expression.
- FALSE
- TRUE
Ans: TRUE
9. Carefully read the question and answer accordingly.
z=lambda a=2:print("Hello")
z()
- Error
- 2
- Hello
- None of these
Ans:Hello
10.Carefully read the question and answer accordingly.
Python supports the creation of anonymous functions at runtime, using a construct called
- pi
- lambda
- anonymous
- None of these
Ans: lambda
11.Does Lambda contains return statements?
- TRUE
- FALSE
Ans: FALSE
12.Lambda is a statement.
- TRUE
- FALSE
Ans: FALSE
13.Lambda contains block of statements
- TRUE
- FALSE
Ans: FALSE
14.The general syntax of a lambda function is ________
- lambda argument_list: expression
- lambda argument_list- expression
- lambda(): expression
- none of the above
Ans: lambda argument_list: expression
Happy Learning – If you require any further information, feel free to contact me.