Home Python math Functions degrees() Python math.degrees() Function Definition math.degrees(x) converts an angle x from radians to degrees using x * (180 / pi) and returns a float.
It pairs naturally with inverse trig functions such as math.atan2() , math.asin() , and math.acos() , which always return radians.
math.degrees() is a function in Python's standard math module: import it with import math and call math.degrees(...), or import the name directly with from math import degrees.
Syntax Import math and pass an angle in radians.
import math
deg = math.degrees(angle_radians) Call What it does math.degrees(math.pi)Returns 180.0. math.degrees(math.tau)Returns 360.0. math.degrees(-math.pi / 2)Returns -90.0. math.degrees(1)Returns approximately 57.295779....
Use math.radians() to convert in the opposite direction before calling sin(), cos(), or tan().
Function signatures math.degrees(x, /)
# returns: float angle in degrees (x * 180 / pi) Parameters Parameter Description xRequired positional angle in radians (int or float).
Return Value Return Value Description floatEquivalent angle in degrees; returns inf, -inf, or nan for special floats.
Python Examples 1. Key radian constants 2. Robotic arm sweeps 3. Format trig results Example 1 — Convert Standard Radian Multiples to Degrees Convert fractions of math.pi and math.tau into degrees.
import math
print(math.degrees(0.0))
print(math.degrees(math.pi / 2.0))
print(math.degrees(math.pi))
print(math.degrees(math.tau))
print(f"{math.degrees(math.pi / 6.0):.1f}") 0.0
90.0
180.0
360.0
30.0 How It Works Exact right, half, and full circles. Dividing math.pi by two gives 90.0, pi gives 180.0, and tau gives 360.0.Clean formatting for fractions. Formatting pi / 6 to one decimal displays 30.0 without float noise.Always returns float. Even integer 0 returns 0.0.Example 2 — Track Robotic Arm Sweep Angles From Radian Encoders Convert angular velocity in rad/s over elapsed seconds into total and wrapped degrees.
import math
rad_per_sec = math.pi / 4.0
for sec in [1, 4, 10]:
total_deg = math.degrees(rad_per_sec * sec)
wrapped = total_deg % 360.0
print(
f"t={sec:>2}s -> total={total_deg:>5.1f} deg "
f"(wrapped={wrapped:>5.1f})"
) t= 1s -> total= 45.0 deg (wrapped= 45.0)
t= 4s -> total=180.0 deg (wrapped=180.0)
t=10s -> total=450.0 deg (wrapped= 90.0) How It Works Multi-turn tracking. Ten seconds at pi / 4 rad/s equals 450.0 total degrees.Unwrapped output. math.degrees() preserves full cumulative rotations rather than clamping at 360.Modulo normalization. Applying % 360.0 extracts the current dial position of 90.0 degrees.Example 3 — Turn atan2() and asin() Outputs Into Degrees Convert radian results from inverse trig calls and inspect special float inputs.
import math
print(math.degrees(math.atan2(3, 3)))
print(math.degrees(-math.pi / 2.0))
print(math.degrees(float("inf"))) How It Works Readable inverse trig. Converting atan2(3, 3) gives an exact 45.0 degree diagonal.Negative angles preserved. Negative radian inputs return negative degrees such as -90.0.Infinity propagates. Passing float("inf") scales to inf without raising.Frequently Asked Questions How does math.degrees() calculate its result? It multiplies the radian angle x by 180.0 / math.pi and returns a float.
Does math.degrees() wrap angles past 360? No. math.degrees(3 * math.pi) returns 540.0. Use math.degrees(x) % 360.0 if you want [0, 360).
What does math.degrees(math.pi) return? Exact 180.0 as a float.
Can math.degrees() raise OverflowError? Only if multiplying a gigantic finite float near 1e308 by 180/pi pushes past ~1.8e308. Normal angles never overflow.
Which function converts degrees back to radians? math.radians(deg) performs the inverse conversion.
Next: math.dist() Return the Euclidean distance between two points p and q.
dist() → About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
12 people found this page helpful
Helpful Share Copy link Suggestion