Math Functions

math.sumprod()

Sum pairwise products of equal-length iterables. Added in 3.12; float inputs use extended-precision intermediates.

Formal Syntax & Structure

python syntaxpython
math.sumprod(p, q, /)

Parameters & Attributes

NameTypeDescription
piterable of numbersNumeric operands from the first iterable.
qiterable of numbersNumeric operands from the second iterable, of equal length.

Return Value

number

Numeric result; concrete type depends on inputs.

Working Example

Example Snippetpython
import mathprint(math.sumprod([1, 2, 3], [4, 5, 6]))
Python Reference