Python Programming - Lambda Functions - Discussion

Discussion Forum : Lambda Functions - General Questions (Q.No. 43)
43.
What does the following lambda function do?
lambda x: x if x % 2 == 0 else None
Doubles even numbers and returns None for odd numbers.
Filters out even numbers and returns None for odd numbers.
Doubles even numbers and returns the original value for odd numbers.
Returns the square of even numbers and None for odd numbers.
Answer: Option
Explanation:
The lambda function filters out even numbers by returning None for them.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.