About Lesson
Lambda Functions
A lambda function is an anonymous function in Python.
In python, normal functions are defined using the def
keyword, anonymous functions are defined using the lambda
keyword.
In python, a lambda function can take a number of arguments, but can only have one expression.
Syntax of Lambda Function
lambda arguments: expression
The expression is executed and the result is returned.
Example
lambda_add = lambda a, b: a + b print(add_lambda(20,20))
In the above program, lambda a, b: a + b
is the lambda function. Here a, b
is the argument and a + b
is the expression that gets evaluated and returned.