Lesson 11: Exponentiation - nolenfelten/Codecademy-Python-Notes GitHub Wiki

All that math can be done on a calculator, so why use Python? Because you can combine math with other data types (e.g. booleans) and commands to create useful programs. Calculators just stick to numbers.

Now let's work with exponents.

eight = 2 ** 3

In the above example, we create a new variable called eight and set it to 8, or the result of 2 to the power to 3 (2^3).

Notice that we use ** instead of * or the multiplication operator.

Create a new variable called eggs and use exponents to set eggs equal 100.

Try raising 10 to the power of 2.

#Set eggs equal to 100 using exponentiation on line 3!

eggs = 10 ** 2

print eggs