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
21. How do you check if a number is odd using lambda?
- lambda x: x % 2 == 0
- lambda x: x % 2 == 1
- lambda x: x / 2 == 1
- lambda x: x * 2 == 1
22. What will be printed: f = lambda a, b: a if a > b else b; print(f(7, 3))?
- 7
- 3
- 10
- True
23. Which data type can lambda functions return?
- Only integers
- Only strings
- Only booleans
- Any data type
24. What is the output of: list(map(lambda x: x*2, [1, 2, 3]))?
- [1, 2, 3]
- [2, 4, 6]
- [1, 4, 9]
- [2, 4, 8]
25. How do you sort strings by their length using lambda?
- sorted(strings, key=lambda x: len(x))
- sorted(strings, key=lambda x: x.length)
- sorted(strings, lambda x: len(x))
- sorted(strings, key=len(x))