Practice With Arithmetic Operators
Practice these programming examples to internalize these concepts.
** operator in Python is used to raise the number on the left to the power of the exponent of the right. That is, in the expression
5 ** 3, 5 is being raised to the 3rd
power. In mathematics, we often see this expression rendered as 5³, and what is really going on is 5 is being multiplied by itself 3 times. In Python, we would get the same result of
125 by running either
5 ** 3 or
5 * 5 * 5.
Let's look at an example with variables:
s = 52.25 t = 7 print(s ** t)
Raising the float
52.25 to the power of
7 through the
** operator results in a large float value returned.