Reference · Math

math.degrees

signature
math.degrees(num) -> float

What it does

An angle in radians as degrees, a float, as Python's math.degrees: the number times 180 / pi. The trigonometric functions work in radians, so this turns their answers into degrees; math.radians goes the other way.

Examples

print(math.degrees(math.pi), math.degrees(math.pi / 2), math.degrees(1))print(math.degrees(math.atan2(1, 1)), math.degrees(math.acos(-1)))
output
180.0 90.0 57.2957795130823245.0 180.0

Edge cases

print(math.degrees(4 * math.pi), math.degrees(-math.pi / 4))print(math.degrees(0))print(math.degrees(math.radians(90)), math.degrees(math.asin(0.5)))print(math.degrees(math.inf), math.degrees(math.nan))
output
720.0 -45.00.090.0 30.000000000000004inf 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.degrees("3.14"))
output
line 1: `math.degrees` expects a number as argument 1, got str
print(math.degrees(float("3.141592653589793")))
output
180.0

Chaining

print(1 | math.atan | math.degrees)print([0, math.pi / 6, math.pi / 2] | map(math.degrees))
output
45.0[0.0, 29.999999999999996, 90.0]

See also

math.radians, math.atan2, math.asin, math.acos

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

Thread 0 posts

On math.degrees(): 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