Master Python with 70+ Hands-on Projects and Get Job-ready - Learn Python
Program 1
# Program for reduce function import functools # def myfunction(a,b): # return a+b # mylist=[2,4,6,8] # add=functools.reduce(myfunction,mylist) # print(add) #Reduce with Lamda function mylist=[2,4,6,8,6,7,8,12,55] value=functools.reduce(lambda a,b:(a+b),mylist) print(value) mylist=[2,3,4,5,6,8] mylist1=list(map(lambda x:(x*x),mylist)) print(mylist1)