Python math.prod()メソッド
例
指定された反復可能要素から要素の積を返します。
# Import math Library
import math
sequence = (2, 2, 2)
#Return the product of the elements
print(math.prod(sequence))
定義と使用法
このmath.prod()
メソッドは、指定されたiterableから要素の積を返します。
構文
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 |