+ 5
How to calculate the average of the elements of a list with the function reduce() ...
How to calculate the average of the elements of a list "with the function reduce()", without having to divide in the end the sum with the number of elements A = [2, 4, 5, 1, 10, 5, 2, 5, 7] prom = reduce(lambda x , y : x + y, A) / len(A) print (prom)
2 Answers
0
@Maria Isabel, el cĂłdigo si usa una funciĂłn.. es una funciĂłn anĂłnima que de realiza con la palabra clave lambda..
Lambda x , y : x + y .. es la funciĂłn.
- 1
Le falta definir la funciĂłn.