Python pow() Function
The Python pow() function is used to calculate power of a number, for example: pow(x, y) returns value equal to x raised to the power y. This function has third optional parameter also, which calculates modulo of the previous with respect to third parameter, for example: pow(x, y, z) returns value equal to x raised to the power y modulo z.
Syntax
pow(x, y, z)
Parameters
x |
Required. Specify a number for base. |
y |
Required. Specify a number for exponent. |
z |
Optional. Specify a number for modulo. |
Example:
In the example below, pow() function is used to calculate power of a given number.
print(pow(2, 4)) print(pow(2, 4, 10))
The output of the above code will be:
16 6
❮ Python Built-in Functions