Last Updated : 14 Apr, 2025
pow() function in Python is a built-in tool that calculates one number raised to the power of another. It also has an optional third part that gives the remainder when dividing the result. Example:
Python
Explanation: pow(3, 2) calculates 32 = 9, where the base is positive and the exponent is positive.
Syntax of pow() functionpow(x, y, mod)
Parameters:
Returns: It returns the value x**y in float or int (depending upon input operands or 2nd argument).
Implementation cases in pow() functionThe below table summarizes the different cases to apply the Python pow() function.
Cases of Python pow() function Examples of pow() functionExample 1: In this example, we are using the third argument in the pow() function, which performs a modulus operation after calculating the power.
Python
Explanation: print(pow(3, 4, 10)) calculates 34 mod 10. First 34=81, then finds the remainder when 81 is divided by 10, which is 1.
Example 2: In this example, we use the pow() function to demonstrate how it handles different combinations of positive and negative bases and exponents, resulting in varying outputs based on their signs.
Python
# +x, +y
print(pow(4, 3))
# -x, +y
print(pow(-4, 3))
# +x, -y
print(pow(4, -3))
# -x, -y
print(pow(-4, -3))
64 -64 0.015625 -0.015625
Explanation:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4