The radians() method in Python number converts angle x from degrees to the radians. The radians() method in Python Number shall be a number or any valid numerical expression. In case the number argument happens to be a positive or negative number, then the Python radians function shall return the output else it returns TypeError.
Here is the syntax for radians() method:
radians(x)
Note - One cannot access this function directly, so it is required to import the math module in Python, and then we are supposed to call this function making use of the math static object.
This method in the Python math module returns the radian value of an angle.
The example below shows the usage of the radians() method.
#!/usr/bin/python import math print "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 the above program is run, it produces the following result:
radians(3) : 0.0523598775598 radians(-3) : -0.0523598775598 radians(0) : 0.0 radians(math.pi) : 0.0548311355616 radians(math.pi/2) : 0.0274155677808 radians(math.pi/4) : 0.0137077838904
Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.