Reference · Math

math.radians

signature
math.radians(num) -> float

What it does

An angle in degrees as radians, a float, as Python's math.radians: the number times pi / 180. The trigonometric functions take radians, so this goes in front of them; math.degrees goes the other way.

Examples

print(math.radians(180), math.radians(90), math.radians(45))print(math.radians(1), math.sin(math.radians(90)))
output
3.141592653589793 1.5707963267948966 0.78539816339744830.017453292519943295 1.0

Edge cases

print(math.radians(540), math.radians(-90))print(math.radians(0))print(math.radians(math.degrees(1)), math.radians(360) == 2 * math.pi)print(math.radians(math.inf), math.radians(math.nan))
output
9.42477796076938 -1.57079632679489660.01.0 trueinf NaN

Errors

A value that is not a number is a runtime error, not an error value: it stops the request. Text from a query or a form is converted first with float; a decimal too.

this one fails
print(math.radians("90"))
output
line 1: `math.radians` expects a number as argument 1, got str
this one fails
print(math.radians(dec("90")))
output
line 1: `math.radians` expects a number as argument 1, got dec (this works on floats: convert a dec with float(x))

Chaining

print(90 | math.radians | math.sin)print([0, 30, 90] | map(math.radians) | map(math.sin) | map((x) => round(x, 10)))
output
1.0[0.0, 0.5, 1.0]

See also

math.degrees, math.sin, math.cos, math.tan

Thread
7Useful? Like it, or add to its thread below.

Thread 0 posts

On math.radians(): questions, tips, corrections, and code that uses it.

No posts yet. The first one opens the thread.

    Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo