Python Quick Quiz V

Question 1: What is a lambda expression in Python?
a) A type of function that cannot have any arguments.
b) An anonymous function that can take any number of arguments but only return a single expression.
c) A built-in Python module for handling mathematical expressions.
d) A special keyword used to define classes in Python.

Question 2: Which of the following is the correct syntax for creating a lambda expression in Python?
a) lambda(x, y): x + y
b) lambda x, y: x + y
c) lambda x, y: return x + y
d) lambda (x, y) -> x + y

Question 3: How are lambda expressions typically used in Python?
a) To define complex functions with multiple statements.
b) To create reusable blocks of code.
c) To implement conditional statements.
d) To write concise and compact functions as arguments to higher-order functions.

1 Like

1.) B) An anonymous function that can take any number of arguments but only return a single expression.
2.) B) lambda x, y: x + y
3.) D) To write concise and compact functions as arguments to higher-order functions.

1 Like