Python Programming - Lambda Functions
Exercise : Lambda Functions - General Questions
- Lambda Functions - General Questions
6.
What is a disadvantage of using lambda functions?
Answer: Option
Explanation:
Lambda functions are limited to a single expression, which may be a disadvantage when more complex logic or multiple statements are required.
7.
What is the main difference between
map()
and filter()
functions when used with lambda functions?
Answer: Option
Explanation:
map()
applies the lambda function to each element of an iterable, while filter()
creates a filter object based on a condition specified by the lambda function.
8.
What is the purpose of the
reduce()
function when used with lambda functions?
Answer: Option
Explanation:
The
reduce()
function is used to accumulate values from an iterable using the lambda function. It successively applies the lambda function to the elements of the iterable.
9.
In Python, can a lambda function have more than one line of code?
Answer: Option
Explanation:
Lambda functions in Python are restricted to a single expression and cannot span multiple lines of code.
10.
Which of the following is a valid use case for lambda functions?
Answer: Option
Explanation:
Lambda functions are suitable for short-term, specific tasks where a full function definition is not necessary. They are often used for quick, one-time operations.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers