map() filter() reduce() in lambda | Python Function | map | filter | reduce | lambda

Publicado em: 19 Fevereiro 2022
no canal de: Mangesh Bagul
2,269
91

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


Nesta página do site você pode assistir ao vídeo on-line map() filter() reduce() in lambda | Python Function | map | filter | reduce | lambda duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Mangesh Bagul 19 Fevereiro 2022, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 2,269 vezes e gostou 91 espectadores. Boa visualização!