Power in Python | Python pow()

Python has various arithmetic operators that take numerical values as input and returns a single numerical value. The arithmetic operators used in Python or any programming language are:

OperatorUse forExample
//Floor divisionx//y

Power (Exponent) in Python

In any programming language including Python, we use ** for Power or exponent. For example, 2**4 means 2 raised to power 4. This is also equivalent to (2*2*2*2). Let’s see this:

x = 3**2
y = 3*-2
Output: 9

Python pow() function for Power

In Python, we have a special function known as pow() for calculating the power or exponent. You can also use this in place of a double asterisk.

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

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

x = pow(4, 3)
Output: 64
It returns 4 to the power of 3
x = pow(4, 3, 5)
Output: 4
Return the value of 4 to the power of 3, modulus 5 (same as (4 * 4 * 4) % 5)


Python Basics
List, Set, Tuple, and Dictionary in Python
Python Reverse List items
Python Round() Function
Python Multiline comment
Power in Python | Python pow()
Python range() Function
Square Root in Python
Python for i in range