① in terms of parameters:
Map () Function:
Map () contains two parameters, the first one is a function, the second is a sequence (list or tuple). Where a function (that is, a function of the first parameter position of a map) can receive one or more parameters.
Reduce () function:
The first parameter of reduce () is a function, and the second is a sequence (list or tuple). However, its function must receive two parameters.
② from the numerical effect on the transfer in terms of:
Map () is the function of the passed in order to each element of the sequence, each element is alone by the function "action" once;
Reduce () is the function of the descendant to the first element of the sequence to get the result, the result will continue to work with the next element (cumulative calculation),
The end result is the interaction of all elements.
Practice:
Calculation: Lambda and reduce implement 1 to 100 cumulative from Functools import reduceprint (Reduce (lambda x,y:sum ([x, Y], range (1,101))) # The first parameter is a function, the second parameter is a sequence print (Map (lambda x,y:sum ([x, Y], range (1,101))) #第一个参数是一个函数, the second argument is a sequence print (list (map) ( Lambda X,y:sum ([x, Y]), Range (1,101), Range (1,101))) #第一个参数是一个函数, the second parameter is a sequence
Printing results:
Python Full Stack development "supplement" the difference between the map function and the reduce function