Python – Lambda Function

Lambda Function in Python

Lambda function is a small anonymous function. These functions are called anonymous because they are not declared in the standard manner by using the def keyword. A lambda function can take any number of arguments, but can only have one expression.

Syntax

lambda arguments expression
Python Lambda Function Tutorial

In Lambda Function the expressions are executed and result is returned.

Single Argument Lambda Function:

x = lambda a : a +10
print(x(5))

Multiple Argument Lambda Function:

x = lambda a, b : a * b
y = x(5,6) # y stores return value
print(y)
Filed under: Python

No comment yet, add your voice below!


Leave a Reply