0% found this document useful (0 votes)
12 views1 page

Lambda Function

A lambda function is an anonymous function that can take multiple arguments but only has one expression. The syntax is 'lambda arguments: expression', and it returns the result of the expression. Examples demonstrate how to use lambda functions to perform operations like addition and multiplication with different numbers of arguments.

Uploaded by

beheraronak2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

Lambda Function

A lambda function is an anonymous function that can take multiple arguments but only has one expression. The syntax is 'lambda arguments: expression', and it returns the result of the expression. Examples demonstrate how to use lambda functions to perform operations like addition and multiplication with different numbers of arguments.

Uploaded by

beheraronak2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

lambda function

A lambda function is a small anonymous function.A lambda function can take any
number of arguments, but can only have one expression.

Syntax
lambda arguments : expression
The expression is executed and the result is returned:

Example-1
x = lambda a : a + 10
print(x(5))

Add 10 to argument a, and return the result.

Example-2

Lambda functions can take any number of arguments:


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

Example-3
Summarize argument a, b, and c and return the result:
x = lambda a, b, c : a + b + c
print(x(5, 6, 2))

You might also like