Simple mathematical expressions

As might be expected, mathematical functions can be strung together in a single expression:

>>> import math
>>> math.sin(math.pi/2)
1.0
>>> math.degrees(math.acos(math.sqrt(3)/2))
30.000000000000004

Note the finite precision here: the exact answer is $\arccos(\sqrt{3}/2) = 30^\circ$.

The fact that the int function rounds down in casting a floating point number to an integer can be used to find the number of digits a positive integer has:

>>> int(math.log10(9999)) + 1
4
>>> int(math.log10(10000)) + 1
5