Python Programming - Lambda Functions
Exercise : Lambda Functions - General Questions
- Lambda Functions - General Questions
11.
In Python, what is the purpose of the
sorted()
function when used with a lambda function?
Answer: Option
Explanation:
The
sorted()
function is used to create a sorted list from the elements of an iterable, with the sorting criteria defined by the lambda function.
12.
What happens if a lambda function is used as an argument for the
key
parameter in the max()
function?
Answer: Option
Explanation:
When a lambda function is used as the
key
parameter in max()
, it defines the sorting criteria for finding the maximum value.
13.
How does the scope of variables work in lambda functions?
Answer: Option
Explanation:
Lambda functions can access variables from the surrounding environment, making them useful for short, specific tasks.
14.
What is the purpose of the
any()
function when used with a lambda function?
Answer: Option
Explanation:
The
any()
function returns True
if at least one element in the iterable satisfies the condition specified by the lambda function.
15.
Which of the following is a valid reason for using a regular function instead of a lambda function?
Answer: Option
Explanation:
Regular functions are more suitable when complex logic, multiple expressions, or statements are needed, as they can span multiple lines of code.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers