Метод Python math.prod()
Пример
Вернуть произведение элементов из заданной итерации:
# Import math Library
import math
sequence = (2, 2, 2)
#Return the product of the elements
print(math.prod(sequence))
Определение и использование
Метод math.prod()
возвращает произведение элементов из заданного итерируемого объекта.
Синтаксис
math.prod(iterable, start)
Значения параметров
Parameter | Description |
---|---|
iterable | Required. Specifies the elements of the iterable whose product is computed by the function |
start | Optional. Specifies the starting value of the product. Default value is 1 |
Технические детали
Возвращаемое значение: | Произведение элементов из итерируемого |
---|---|
Версия Python: | 3,8 |