degrees() and radians() in Python (original) (raw)
Last Updated : 11 Jul, 2025
In geometry and trigonometry, we often switch between **degrees and **radians. Python’s math module provides two simple functions to handle these conversions:
- **math.radians() – Converts degrees to radians
- **math.degrees() – Converts radians to degrees
Let’s explore both with examples:
math.radians()
This function takes a degree value and returns its equivalent in radians.
Syntax
math.radians(x)
**Parameters:
- x: Angle in degrees (**float or int)
**Returns: Angle in radians (**float)
Example 1: Convert Degrees to Radians
Python `
import math
x = 180 print("Radians:", math.radians(x))
`
Output
Radians: 3.141592653589793
**Explanation: **180 degrees is exactly **π radians.
Example 2: Convert 1 Degree and Fractional Degree
Python `
import math
a = 1 b = 180 / math.pi
print("1° in Radians:", math.radians(a)) print("180/π° in Radians:", math.radians(b))
`
Output
1° in Radians: 0.017453292519943295 180/π° in Radians: 1.0
**Explanation: **180/π degrees equals exactly **1 radian.
math.degrees()
This function takes a radian value and returns its equivalent in degrees.
Syntax
math.degrees(x)
**Parameters:
- x: Angle in radians (**float or int)
**Returns: Angle in degrees (**float)
Example 3: Convert Radians to Degrees
Python `
import math
x = math.pi print("Degrees:", math.degrees(x))
`
**Explanation: **π radians is exactly **180 degrees.
Example 4: Convert 1 Radian and π/180 Radians
Python `
import math
a = 1 b = math.pi / 180
print("1 Radian in Degrees:", math.degrees(a)) print("π/180 Radians in Degrees:", math.degrees(b))
`
**Explanation: 1 radian ≈ 57.3°, and π/180 radians equals 1 degree.
Applications
- Geometry and trigonometry problems
- Astronomical computations
- Graphing and simulations
- Rotational transformations in graphics
**Related Articles: