Skip to main content

pow()

The pow() function in Python is a built-in function that is used to calculate the power of a number. It takes two arguments, the base and the exponent, and returns the result of raising the base to the power of the exponent.

Parameter Values

Parameter Description
base

The base number to be raised to a power.

exp

The exponent that the base is raised to.

Return Values

The pow() function can return int, float, or complex types.

How to Use pow() in Python

Example 1:

Return the value of x to the power of y

result = pow(3, 4)
print(result) # Output: 81
Example 2:

Return the value of x to the power of y, modulo z

result = pow(2, 5, 10)
print(result) # Output: 2
Example 3:

Using pow() with negative exponents

base = 2
exponent = -3
result = pow(base, exponent)
print(result) # Output: 0.125