Skip to Content

The Python double asterisk operator ** is a simple mathematical operator that performs the equivalent of the math.pow() function and permits only two numbers as its parameters.

The first number is the base number and the number following the double asterisk syntax ** is the power exponent.

For example, if you wanted to know which mathematical operator is used to raise five to the second power in Python you would perform this operation using the double asterisk operator, like so in the REPL:

>>> 5 ** 2

Similarly, you could also use the double-asterisk operator to perform square roots, cube roots, quartic roots and all other sorts of roots – if you can remember that performing a root calculation is simply to change the power parameter (that second number after the **) to be a fraction.

For example, if you want to calculate the square root of 25 you could use the double asterisk operator in the REPL like so:

>>> 25 ** (1/2)

Now you don't need to import the math library into your code to perform basic pow() and sqrt() functions.