Skip to content

Latest commit

 

History

History
22 lines (15 loc) · 677 Bytes

lambda_functions.md

File metadata and controls

22 lines (15 loc) · 677 Bytes

Back

Lambda Functions


In Python, lambda expressions (or lambda forms) are used to construct anonymous functions. To do so, you will use the lambda keyword (just as you use def to define normal functions).

Every anonymous function you define in Python will have 3 essential parts:

  • The lambda keyword.
  • The parameters (or bound variables), and
  • The function body.

Example of Lambda Function:

double = lambda x: x * 2

# Output: 10
print(double(5))

In the above program, lambda x: x * 2 is the lambda function. Here x is the argument and x * 2 is the expression that gets evaluated and returned.