all Python 3mathterm
math.radians
trigonometry
Converts an angle from degrees to radians. math.radians(180) → 3.14159... Needed by the trigonometric functions.
Syntax
math.radians(x)
Every trigonometric function in math expects radians and has no way to warn you otherwise: math.sin(30) does not fail, it returns the sine of 30 radians — a normal-looking number that silently breaks the answer. Convert at the call site instead: math.sin(math.radians(30)).
Examples
import math
print(math.radians(180)) # → 3.14159...
print(math.radians(90)) # → 1.5707...
print(math.radians(0)) # → 0.0
print(math.radians(360)) # → 6.2831...
print(math.radians(45)) # → 0.7853...
print(math.radians(60)) # → 1.0471...
See also
Open in the full glossarydocs.python.orgReport an inaccuracy