Metoda Python math.prod().
Příklad
Vraťte součin prvků z dané iterace:
# Import math Library
import math
sequence = (2, 2, 2)
#Return the product of the elements
print(math.prod(sequence))
Definice a použití
Metoda math.prod()
vrací součin prvků z dané iterovatelnosti.
Syntax
math.prod(iterable, start)
Hodnoty parametrů
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 |
Technické údaje
Návratová hodnota: | Součin prvků z iterovatelného |
---|---|
Verze Pythonu: | 3.8 |