What is Lambda Function?
Brief Intro
A lambda function is a anonymous function with syntax lambda args: expression
. The expression is executed on the arguments and the result is returned. Each lambda function consists of 3 parts:
- Keyword lambda
- A bound variable x
- Body of the expression
Syntax — Single Variable
A simple example: square = lambda x: x**2
is equivalent to the standard Python function definition as follows: