How to calculate a square root?¶
import math
print(math.sqrt(49))
How to calculate a trigonometric function?¶
import math
print(math.sin(math.pi / 2))
How to calculate an exponential function?¶
import math
print(math.exp(1.0) == math.e)
How to calculate a logarithm?¶
import math
print(math.log(256, 2))
See also
The builtin math module contains mathematical functions similar to a scientific calculator. In the module, you find various trigonometric and exponential functions. In addition the two constants pi and e are included.