Problem Statement
What is a lambda function in Python?
Explanation
A lambda function is an anonymous, one-line function defined using the keyword lambda. It can take any number of inputs but only one expression, which is automatically returned.
They are used when a short function is needed temporarily, for example as a key in sorting or inside functions like map and filter. Though concise, excessive use of lambda can hurt readability compared to normal function definitions.
Code Solution
SolutionRead Only
square = lambda x: x*x print(square(4))
