Anonymous user
Sum and product of an array: Difference between revisions
→{{header|Python}}
Line 514:
from functools import reduce
from operator import mul, add
sum = reduce(add, numbers) # note: this version doesn't work with empty lists
sum = reduce(
product = reduce(mul, numbers) # note: this version doesn't work with empty lists
product = reduce(mul, numbers, 1)
{{libheader|numpy}}
|