Python math.degrees() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
math module

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.

python
import math

deg = math.degrees(angle_radians)
CallWhat 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
python
math.degrees(x, /)
# returns: float angle in degrees (x * 180 / pi)

Parameters

ParameterDescription
xRequired positional angle in radians (int or float).

Return Value

Return ValueDescription
floatEquivalent angle in degrees; returns inf, -inf, or nan for special floats.

Python Examples

Example 1 — Convert Standard Radian Multiples to Degrees

Convert fractions of math.pi and math.tau into degrees.

python
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}")

How It Works

  1. Exact right, half, and full circles. Dividing math.pi by two gives 90.0, pi gives 180.0, and tau gives 360.0.
  2. Clean formatting for fractions. Formatting pi / 6 to one decimal displays 30.0 without float noise.
  3. 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.

python
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})"
    )

How It Works

  1. Multi-turn tracking. Ten seconds at pi / 4 rad/s equals 450.0 total degrees.
  2. Unwrapped output. math.degrees() preserves full cumulative rotations rather than clamping at 360.
  3. 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.

python
import math

print(math.degrees(math.atan2(3, 3)))
print(math.degrees(-math.pi / 2.0))
print(math.degrees(float("inf")))

How It Works

  1. Readable inverse trig. Converting atan2(3, 3) gives an exact 45.0 degree diagonal.
  2. Negative angles preserved. Negative radian inputs return negative degrees such as -90.0.
  3. Infinity propagates. Passing float("inf") scales to inf without raising.

Frequently Asked Questions

It multiplies the radian angle x by 180.0 / math.pi and returns a float.
No. math.degrees(3 * math.pi) returns 540.0. Use math.degrees(x) % 360.0 if you want [0, 360).
Exact 180.0 as a float.
Only if multiplying a gigantic finite float near 1e308 by 180/pi pushes past ~1.8e308. Normal angles never overflow.
math.radians(deg) performs the inverse conversion.

Next: math.dist()

Return the Euclidean distance between two points p and q.

dist() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

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