pow(x, y) function in Python is used to find value of x raised to the power of y (xy).

Syntax

pow(x, y, z)

Parameters

Python pow() function parameters
ParameterConditionDescription
xRequiredBase
yRequiredExponent
zOptionalModulus

The third parameter (z) is optional, but when specified pow() function returns xy%z.

Let’s see some examples to get a better understanding.

Examples

print(pow(2,4))
#output 16

We can also achieve the above result by using 2**4 in Python.

print(pow(2+3j, 3))
#output (-46+9j)

Example of pow() when all 3 parameters are specified.

print(pow(2,4,6))
#output 4 (16%6=4)

When y parameter is negative then pow() returns float number as the result.

print(pow(2, -4))
#output 0.0625

If you have any doubts or suggestions then please comment below.

Leave a Reply