Lambda Functions Questions and Answers

Take Exam

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
Show Answer Report

22. What will be printed: f = lambda a, b: a if a > b else b; print(f(7, 3))?

  • 7
  • 3
  • 10
  • True
Show Answer Report

23. Which data type can lambda functions return?

  • Only integers
  • Only strings
  • Only booleans
  • Any data type
Show Answer Report

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]
Show Answer Report

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))
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test