WHAT ARE LAMBDA FUNCTIONS IN PYTHON


Definition of Python Lambda Functions

Lambda Functions are anonymous or unnamed short functions.

Syntax of Lambda Functions in Python

lambda arguments: expression 

Examples of Python Lambda Functions

Lambda function with single argument

Code

add = lambda num: num + 5  
print( add(2) )

Output

7

Lambda function with multiple arguments

Lambda functions can take any number of arguments

Code

x = lambda a, b : a * b
print(x(5, 5))

output

25

Leave a Reply

Your email address will not be published. Required fields are marked *