Python radians() function
Description
radians() The method converts degrees to radians.
Syntax
The syntax of the radians() method is as follows:
The relationship between degrees and radians is: 2π radians = 360°. Thus 1°≈0.0174533 radians and 1 radian≈57.29578°.
-
- Degrees to radians formula: radians = degrees / 180 × π
-
- Formula for converting radians to degrees: degrees = radians x 180 / pi
import math
math.radians(x)
**Note:** radians() cannot be accessed directly; you need to import the math module and call the method through the static math object.
Parameters
- x -- an angle value, in degrees ° by default.
Return Value
Returns the radian value of an angle.
Example
The following shows examples of using the radians() method:
Example
#!/usr/bin/python
import
math
"radians(90) : "
,
math
.
radians
(
90
)
"radians(45) : "
,
math
.
radians
(
45
)
"radians(30) : "
,
math
.
radians
(
30
)
Running the example above produces:
radians(90) : 1.57079632679
radians(45) : 0.785398163397
radians(30) : 0.523598775598
Python Numbers