Lambda Functions Questions and Answers
Practice ModeShowing 10 of 25 questions
Q11
Which statement about lambda functions is TRUE?
Answer: Option C
Explanation: Lambda functions can be used wherever function objects are required
Q12
What will be the output: sorted([(1, 2), (3, 1), (5, 0)], key=lambda x: x[1])?
Answer: Option A
Explanation: The lambda function extracts the second element of each tuple for sorting
Q13
How can you square all numbers in a list using lambda?
Answer: Option A
Explanation: map() with lambda can transform each element in an iterable
Q14
What does this lambda do: lambda s: s[::-1]?
Answer: Option B
Explanation: String slicing with [::-1] reverses a string
Q15
Which is the correct way to use lambda with filter to get numbers greater than 10?
Answer: Option C
Explanation: filter() keeps elements where lambda returns True
Q16
What is the output of: (lambda x: x if x > 0 else -x)(-5)?
Answer: Option B
Explanation: This lambda returns absolute value of a number
Q17
How do you multiply each element by 2 using lambda and map?
Answer: Option A
Explanation: map() applies transformation function to each element
Q18
What will this code return: list(filter(lambda x: len(x) > 3, ['cat', 'dog', 'elephant']))?
Answer: Option B
Explanation: filter() keeps elements where condition is True
Q19
Which operator is used in lambda for exponentiation?
Answer: Option B
Explanation: ** is the exponentiation operator in Python
Q20
What is the result of: max([(1, 2), (3, 1), (2, 4)], key=lambda x: x[0])?
Answer: Option B
Explanation: max() with key function finds maximum based on specified element