Python pow() Function

❮ Built-in Functions


Example

Return the value of 4 to the power of 3 (same as 4 * 4 * 4):

x = pow(4, 3)
Try it Yourself »

Definition and Usage

The pow() function returns the value of x to the power of y (xy).

If a third parameter is present, it returns x to the power of y, modulus z.


Syntax

pow(x, y, z)

Parameter Values

Parameter Description
x A number, the base
y A number, the exponent
z Optional. A number, the modulus

More Examples

Example

Return the value of 4 to the power of 3, modulus 5 (same as (4 * 4 * 4) % 5):

x = pow(4, 3, 5)
Try it Yourself »

❮ Built-in Functions

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.