Python Map Filter Reduce using lambda function in Hindi

Python Map() ,Filter(), Reduce() – In Function ka istemal python me jyada tar lambda function me hota hai |

Python Map Filter Reduce in hindi

Map() ,Filter(), Reduce() in python ko Or Accha Samanjh ne ke liye iske A To Z example dekhte |

Python Map Filter Reduce
Python Map Filter Reduce

How To Create python lambda function

Lambda Expression ko python me kese create kiya jata hai aap niche diye example 1 me dekh sakte hai |

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 with filter, map, reduce

Dosto mujhe ummed hai ki aap Python filter, map, reduce in hindi 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 Map Filter Reduce using lambda function in Hindi
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 Map Filter Reduce using lambda function in Hindi

Leave a Reply

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

error

Enjoy this blog? Please spread the word :)