Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
lambda_filter_map_reduce.py
#python 3.5.2 #Lambda expression/Annonyms function #1) lam=lambda a,b : a+b res=lam(10,20) print(res) #2)filter(function,sequence/iterable) l=[1,2,3,4,5,6,7,8,9] #filter even list,odd list fromthe list using filter() even=list(filter(lambda a:a%2==0,l)) odd=list(filter(lambda a:a%2!=0,l)) print(odd) print(even) #using map(function,iterable/sequence) find the square of the list elements square=list(map(lambda a:a**2,l)) print(square) #using reduce(function,sequence) find the sum of elements of a list import functools sum=functools.reduce(lambda a,b:a+b,l) print(sum)
run
|
edit
|
history
|
help
0
Python Practice
teretere
Depth First Search - Find if path exists
Guessing game
Adivina el número
rstring
Stk String replace
we
PyRegSearch
error