Lambda Functions Questions and Answers
Python Programming - Lambda Functions Questions with Answers explore anonymous functions used for short, inline operations. These Python Lambda Functions Questions are important for TCS, Wipro, and SSC exams focusing on functional programming
Lambda Functions
Showing 10 of
25 questions
1. What is a lambda function in Python?
- A named function defined with def keyword
- An anonymous function defined with lambda keyword
- A built-in function for mathematical operations
- A function that returns multiple values
2. Which of the following is the correct syntax for a lambda function?
- def lambda(x): return x*2
- lambda x: x*2
- function lambda(x) {return x*2}
- lambda function(x): return x*2
4. Which of the following is a limitation of lambda functions?
- They cannot have multiple arguments
- They cannot return values
- They can only contain a single expression
- They cannot be assigned to variables
5. How do you create a lambda function with two arguments?
- lambda x y: x + y
- lambda (x, y): x + y
- lambda x, y: x + y
- lambda [x, y]: x + y
7. Which built-in function is commonly used with lambda functions?
- print()
- input()
- map()
- range()
8. What will this code output: list(map(lambda x: x.upper(), ['a', 'b', 'c']))?
- ['A', 'B', 'C']
- ['a', 'b', 'c']
- [65, 66, 67]
- Error
9. How do you filter even numbers using lambda?
- filter(lambda x: x % 2 == 0, numbers)
- filter(lambda x: x / 2, numbers)
- filter(lambda x: x * 2, numbers)
- filter(lambda x: x == even, numbers)