map() filter() reduce() in lambda | Python Function | map | filter | reduce | lambda #shorts #python

preview_player
Показать описание
Use filter,map,reduce in lambda functions.

items = [1,2,3,4,5,6]

code:
# map function
items = [1,2,3,4,5,6]
new_items = list(map(lambda x:x*x,items))
print(new_items)
Output: [1, 4, 9, 16, 25, 36]

# filter function
items = [1,2,3,4,5,6]
new_items = list(filter(lambda x:(x%2==0),items))
print(new_items)
Output: [2, 4, 6]

# reduce function
from functools import reduce
items = [1,2,3,4,5,6]
new_items = reduce((lambda x,y:x+y),items)
print(new_items)
Output: 21

#softwareengineer #pythonlearning #computerscience #coder #phyton #python3 #pythoncode #pythonprogramming #shorts #youtubeshorts
Рекомендации по теме
Комментарии
Автор

Thankyou sir bro anyone
I understand very well and easily

affairs