Python pow() Function

Example

Returns 5 to the power of 3 (the same as 5 * 5 * 5):

x = pow(5, 3)

Run Instance

Definition and Usage

The value of x raised to the power of y (xy).

If the third parameter is provided, it returns x raised to the power of y modulo z.

Syntax

pow(x, y, z)

Parameter Value

Parameter Description
x Number, base.
y Number, exponent.
z Optional. Number, modulus.

More Examples

Example

Returns the remainder of 5 to the power of 3 modulo 4 (equivalent to (5 * 5 * 5) % 4):

x = pow(5, 3, 4)

Run Instance