Reference · Math
math.degrees
signature
math.degrees(num) -> floatWhat 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.0Edge cases
- Nothing is wrapped:
4 * piis720.0, not0. - The answer is a float even for
0. - Round trips are exact in the usual cases:
math.degrees(math.radians(90))is90.0; computed angles can miss by a digit, asmath.asin(0.5)does. infgivesinf,NaNgivesNaN; neither is an error.
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 NaNErrors
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 strprint(math.degrees(float("3.141592653589793")))output
180.0Chaining
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
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