Python/ref math prod
来自菜鸟教程
<languages />
Python math.prod()方法
例
从给定的迭代器返回元素的乘积:
# Import math Library
import math
sequence = (2, 2, 2)
#Return the product of the elements
print(math.prod(sequence))
定义和用法
The
math.prod()
方法从给定的Iterable返回元素的乘积。
句法
math.prod(iterable, start)
参数值
| 参数 | 描述 |
|---|---|
| iterable | 需要。指定由函数计算乘积的Iterable的元素 |
| start | 可选的。指定产品的起始值。预设值为1 |
技术细节
| 返回值: | 元素的乘积
iterable |
| PHP版本: | 3.8 |