Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python math.prod() Method

Python math.prod() Method

Python math Module Python math Module

Python math.prod() The method computes the product of all elements in an iterable.

Python version: 3.8

Syntax

The syntax of the math.prod() method is as follows:

math.prod(iterable, start)

Parameter Description:

Return Value

A floating-point value or integer, the product of the iterable's elements; the type depends on the elements, returning an integer if all elements are integers and a floating-point number if any element is a float.

Example

The following example computes the product of iterable elements:

Example

Import the math package

import

math

Compute the product of iterable elements

sequence

=

(

2

,

2

,

2

)

print

(

math

.

prod

(

sequence

)

)

Output result:


8

Python math Module Python math Module