Python lambda function in hindi | lambda with filter, map, reduce examples

Lambda Expression – python lambda function or ( Anonymous Functions ) hai | or python me ye dono ek hi chiz hai |

PythonLambda functions in Hindi

Lambda functions mei keval ek hi expression define kiya ja sakta hai। Lambda functions ka syntax multiple expressions use kiya jana allow nhi karta hai । yahi karan hai ki lambda functions ko one line functions bhi kaha jata hai |

Python Create lambda function

Syntax :

 lambda arguments: expression
  • Arguments :- Matlab aap jese function me arguments pass karte hai wese hi aap isme arguments pass kar sakte hai |
  • Expression :- Matlab aapko jo bhi lambda expression se kar wana hai to aapko yha par expression deni hogi |

Aap upper diye gye syntax ko dekh sakte hai.

lambda expression in python ko Or Accha Samanjh ne ke liye iske A To Z example dekhte |

Python lambda function in hindi | lambda with filter, map, reduce examples

How To Create python lambda function

Example 1 :-

Lamfunc = lambda x1, x2 : x1 + x2
 
res = Lamfunc(3,6)    
print(res)

Aap Upper Diye Gye Program ko samanjh sakte hai.

Output :-

9

Aap upper Diye gye output ko dekh kar program ko samanjh sakte hai.

Python mei lambda functions ka istemal jyada tar filter(), map() or reduce() functions mei argument ke rup mei istemal kiya jata hai |

Use of lambda() with filter()

python mei filter ek eesa function hai jo logic ke aadhar par kisi list mei se data ko filter karke extract karne ke liye istemal kiya jata hai | is function mei aap ek function or ek list ko argument ke rup mei pass karte hai |

Example 2 :-

# find even number is this list using lambda function

data  = [1,2,3,4,5,5,6,6,7,9,10]
var = list(filter(lambda x : x%2==0 , data))

print(var)

Upper diye gye program me filter function ka istemal karte ham even number find kar rhe hai|

Output :-

[2, 4, 6, 6, 10]  

Program me upper ouput ko dekh sakte hai ki hamne filter function & lambda function ka istemal karke even find ko data list mei find kar liya hai|

Use of lambda() with Map()

python mei map ek eesa function hai jo kisi list mei se data ko map karta hai | is function mei aap ek function or ek list ko argument ke rup mei pass karte hai |

Example 3 :-

# find list ka square using map function
# map() with lambda() 

li = [5, 7, 22, 97, 54, 62, 77, 23, 73, 61] 
square_list = list(map(lambda x: x**2 , li)) 

print(square_list) 

Upper diye gye program me map function ka istemal karte ham list square number find kar rhe hai |

Output :-

[25, 49, 484, 9409, 2916, 3844, 5929, 529, 5329, 3721] 

Program me upper ouput ko dekh sakte hai ki hamne map function & lambda function ka istemal karke square find kar liya hai |

Use of lambda() with Reduce()

python mei reduce function ek eesa function hai jo kisi list mei se data ko reduce karta hai | is function mei aap ek function or ek list ko argument ke rup mei pass karte hai |

Example 4 :-


# reduce() with lambda() 
# to get sum of a list 

from functools import reduce
li = [5, 8, 10, 20, 50, 100] 

sum = reduce((lambda x, y: x + y), li) 
print (sum) 

Upper diye gye program me reduce function ka istemal karte ham list ke all number sum karke find kar rhe hai |

Output :-

193

Program me upper ouput ko dekh sakte hai ki hamne reduce function & lambda function ka istemal karke list ka sum find kar liya hai |

Python lambda (Anonymous Functions) | filter, map, reduce

Dosto mujhe ummed hai ki aap Python lambda function in hindi| filter, map, reduce ko acchi tarah se samanj gye honge agar aap ko ye post acchi lage to mere is website ko jarur follow kre or ha agar aap video bhi dekhna chahte hai to aap mere channel ko bhi subscribe kar sakte hai. channel ka link aapko home page par mil jayega |

Summary
Review Date
Reviewed Item
Python lambda (Anonymous Functions) | filter, map, reduce
Author Rating
51star1star1star1star1star

Danish Ali

I Am a 1st Sem BCA Student & I have Skills C, C++ ,Python, HTML,CSS, Computer & Advance Hacking & Blogger & YouTuber.

One thought on “Python lambda function in hindi | lambda with filter, map, reduce examples

Leave a Reply

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

error

Enjoy this blog? Please spread the word :)