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
linked_lists_2
lesson3 part3
PyRef
Ej2_python_204676887
Emails_Python
Right_Align_Text
quiz1
BubbleSort
add function
Принцип наименьшего времени Ферма