Arithmetic Operators - Exponentiation

The exponentiation operator ** is used to raise a number to a power.

Let's say you have the number 2 and you want to raise it to the power of 3. You could do this using the exponentiation operator like so:

Loading Code . . .

In this example, 2 ** 3 is read as "2 to the power of 3", which is equal to 8. It is the same as multiplying 2 by itself 3 times ( 2 * 2 * 2 = 8 )

You can also use variables in conjunction with the exponentiation operator:

Loading Code . . .

Here, we're using the variables base and exponent to calculate 4 to the power of 2, which is equal to 16.

© 2024 - ®Mewters