Next / Previous / Contents / TCC Help System / NM Tech homepage

20.32. pow(): Exponentiation

There are two ways to compute xy in Python. You can write it as “x**y”. There is also a function that does the same thing:

pow(x, y)

For integer arithmetic, the function also has a three-argument form that computes xy%z, but more efficiently than if you used that expression:

pow(x, y, z)

Examples:

>>> 2**4
16
>>> pow(2,4)
16
>>> pow(2.5, 4.5)
61.763235550163657
>>> (2**9)%3
2
>>> pow(2,9,3)
2