This article mainly introduces the radians () method for converting degrees to radians in Python. It is the basic knowledge in Python. For more information, see radians () method to convert the angle to radian angle x.
Syntax
The following is the syntax of the radians () method:
Note: This function cannot be directly accessed. Therefore, we need to import the math module and then use the static object of math to call this function.
Parameters
- X -- this must be a value.
Return Value
This method returns the radians of an angle.
Example
The following example shows how to use the radians () method.
#!/usr/bin/pythonimport mathprint "radians(3) : ", math.radians(3)print "radians(-3) : ", math.radians(-3)print "radians(0) : ", math.radians(0)print "radians(math.pi) : ", math.radians(math.pi)print "radians(math.pi/2) : ", math.radians(math.pi/2)print "radians(math.pi/4) : ", math.radians(math.pi/4)
When we run the above program, it will produce the following results:
radians(3) : 0.0523598775598radians(-3) : -0.0523598775598radians(0) : 0.0radians(math.pi) : 0.0548311355616radians(math.pi/2) : 0.0274155677808radians(math.pi/4) : 0.0137077838904