Python – Math – Exponents / Powers

There is actually a direct operator to calculate exponents in python; you don’t need to use any math libraries/etc.

For example:

#Calculate 4 squared.
4 ** 2
16

#Calculate 2 cubed.
2 ** 3
8

Leave a comment