The math.prod()
function is used to compute the product of all the numbers present in an iterable such as a list, tuple, dictionary, set, or any other user-defined iterable.
math.prod(iterable, start = 1)
The optional start
argument is used to initialize the product with the specified value; it defaults to 1.
import math
print(math.prod([]))
print(math.prod([1, 2, 3]))
print(math.prod(range(1, 6)))
print(math.prod((i for i in range(1, 11))))
print(math.prod({0.5, 0.6, 0.7, 0.8}))