Loading

Quipoin Menu

Learn • Practice • Grow

python / Lambda Functions
mcq
Direction: Choose the correct option

Q1.

How do you define a lambda function?
A. lambda x: x+1
B. function(x): return x+1
C. func x: x+1
D. def lambda x: x+1
Direction: Choose the correct option

Q2.

What does `lambda x, y: x + y` return?
A. A function object
B. The sum of x and y
D. An error
Direction: Choose the correct option

Q3.

What is the output of `(lambda x: x*2)(3)`?
A. 3
B. 6
C. Error
D. 9
Direction: Choose the correct option

Q4.

Where are lambda functions commonly used?
A. As decorators
B. As arguments to functions like `map` and `filter`
C. As modules
D. As classes
Direction: Choose the correct option

Q5.

What does `list(map(lambda x: x*2, [1,2,3]))` produce?
A. [1,4,9]
B. [2,4,6]
C. [1,2,3]
D. [2,4,6]
Direction: Choose the correct option

Q6.

What does `filter(lambda x: x>2, [1,2,3,4])` return?
A. [3,4]
B. [3,4]
C. A filter object with 3,4
D. [1,2]
Direction: Choose the correct option

Q7.

Can lambda functions contain statements?
A. No, only expressions
B. Yes, if wrapped in a block
C. Yes, multiple statements
D. No, they are limited to single expressions
Direction: Choose the correct option

Q8.

What is the result of `sorted(['abc','de','f'], key=lambda s: len(s))`?
A. ['abc','de','f']
B. ['f','de','abc']
C. ['de','f','abc']
D. ['f','de','abc']
Direction: Choose the correct option

Q9.

What does `(lambda a, b: a if a > b else b)(5, 3)` return?
A. 5
C. 3
D. 8
Direction: Choose the correct option

Q10.

How do you assign a lambda to a variable?
A. f = lambda x: x+1
B. def f = lambda x: x+1
C. f = def lambda x: x+1
D. lambda f = x: x+1