Python pow() built-in function

From the Python 3 documentation

The pow() function returns the power of a number.It takes two or three arguments: pow(base, exp): Returns base raised to the power of exp (base ** exp). pow(base, exp, mod): Returns (base ** exp) % mod (for modular arithmetic). Result is computed more efficiently than base ** exp % mod, if mod arg is present.

Example

# Basic exponentiation
>>> pow(2, 3)
# 8

# Using three arguments (modular exponentiation)
>>> pow(2, 3, 5)
# 3  (since 2^3 = 8, and 8 % 5 = 3)

# Works with negative exponents (returns float)
>>> pow(2, -3)
# 0.125  (since 2^(-3) = 1/8)

Ups! Nothing here yet!

This is a great opportunity for you to collaborate! Hit the link at the end of this page and add some examples and a brief description. If you don't know where to start, the Python 3 documentation will lead you in the right direction.

Subscribe to pythoncheatsheet.org

Join 14,100+ Python developers in a two times a month and bullshit free publication , full of interesting, relevant links.