Important Notice:

Course Content
The Calendar Module
Library Function/Predefined Functions
0/4
Sys Module
Library Function/Predefined Functions
0/2
OS Module
Library Function/Predefined Functions
0/2
Functions in Python (Chapter-10) M3-R5
About Lesson

Note 1:-       Lambda keyword के बाद arguments को define किया जाता है। जो की Normal functions की ही तरह python में lambda functions को भी आप अपनी इच्छा अनुसार कितने भी arguments pass कर सकते है।

lambda <x1, x2, x3, x4……xN> : <expression>

a=lambda x,y,z:x+y+z

print(a(10,20,30))

Output

60

 

x=lambda a,b:a*b

print(x(10,2))

Output

20

 

 

Note 2:-       Arguments के बाद colon (:) लगाकर expression define किया जाता है। इस expression को आप function की body की तरह समझ सकते है।

lambda <x1,x2,x3,….xN> : <single – Expression>

Note 3:-               lambda functions को define करके एक object को assign किया जाता है। इसके बाद उस object के द्वारा ही आप lambda function को use करते है। यह एक function object होता है। 

obj = lambda <x1, x2, x3,…..xN> : <expression> 

Note 4:-               Lambda functions में केवल एक ही expression define किया जा सकता है। Lambda functions का syntax multiple expressions use किया जाना allow नहीं करता है। यही कारण है की lambda functions को one line functions भी कहा जाता है।

Note 5:-               Python में lambda functions का प्रयोग अधिकतर filter(), map() और reduce() functions में argument के रूप में किया जाता है।

 

 

Note 1:-       Arguments are defined after the lambda keyword. Just like normal functions, you can pass any number of arguments as per your wish to lambda functions in Python.

lambda <x1, x2, x3, x4……xN> : <expression>

a=lambda x,y,z:x+y+z

print(a(10,20,30))

Output

60

 

x=lambda a,b:a*b

print(x(10,2))

Output

20

 

 

Note 2:-       The expression is defined by putting a colon (:) after the arguments. You can understand this expression like the body of a function.

lambda <x1,x2,x3,….xN> : <single – Expression>

Note 3:-               Lambda functions are defined and assigned to an object. After this, you use the lambda function through that object only. This is a function object.

obj = lambda <x1, x2, x3,…..xN> : <expression> 

Note 4:-               Only one expression can be defined in Lambda functions. The syntax of Lambda functions does not allow multiple expressions to be used. This is why lambda functions are also called one line functions.

Note 5:-       In Python, lambda functions are mostly used as arguments in filter(), map() and reduce() functions.

error: Content is protected !!