Lambda Functions Questions and Answers

Practice Mode
Showing 10 of 25 questions
Q1
What is a lambda function in Python?
  • A A named function defined with def keyword
  • B An anonymous function defined with lambda keyword
  • C A built-in function for mathematical operations
  • D A function that returns multiple values
Answer: Option B
Explanation: Lambda functions are anonymous functions defined with the lambda keyword
Q2
Which of the following is the correct syntax for a lambda function?
  • A def lambda(x): return x*2
  • B lambda x: x*2
  • C function lambda(x) {return x*2}
  • D lambda function(x): return x*2
Answer: Option B
Explanation: Lambda functions use the syntax: lambda arguments: expression
Q3
What will be the output of: (lambda x: x**2)(5)?
  • A 10
  • B 25
  • C 125
  • D 52
Answer: Option B
Explanation: Lambda function squares the input value
Q4
Which of the following is a limitation of lambda functions?
  • A They cannot have multiple arguments
  • B They cannot return values
  • C They can only contain a single expression
  • D They cannot be assigned to variables
Answer: Option C
Explanation: Lambda functions can only contain expressions, not statements
Q5
How do you create a lambda function with two arguments?
  • A lambda x y: x + y
  • B lambda (x, y): x + y
  • C lambda x, y: x + y
  • D lambda [x, y]: x + y
Answer: Option C
Explanation: Multiple arguments are separated by commas in lambda functions
Q6
What is the output of: f = lambda x, y: x + y; print(f(3, 4))?
  • A 7
  • B 34
  • C 12
  • D Error
Answer: Option A
Explanation: Lambda function adds two numbers
Q7
Which built-in function is commonly used with lambda functions?
  • A print()
  • B input()
  • C map()
  • D range()
Answer: Option C
Explanation: map(), filter(), and sorted() are commonly used with lambda functions
Q8
What will this code output: list(map(lambda x: x.upper(), ['a', 'b', 'c']))?
  • A ['A', 'B', 'C']
  • B ['a', 'b', 'c']
  • C [65, 66, 67]
  • D Error
Answer: Option A
Explanation: map() applies lambda function to convert each element to uppercase
Q9
How do you filter even numbers using lambda?
  • A filter(lambda x: x % 2 == 0, numbers)
  • B filter(lambda x: x / 2, numbers)
  • C filter(lambda x: x * 2, numbers)
  • D filter(lambda x: x == even, numbers)
Answer: Option A
Explanation: filter() with lambda can be used to select elements based on condition
Q10
What is the result of: (lambda x, y, z: x+y+z)(1, 2, 3)?
  • A 6
  • B 123
  • C 5
  • D Error
Answer: Option A
Explanation: Lambda function with three parameters adds all three values
Questions and Answers for Competitive Exams Various Entrance Test