Latest web development tutorials

Python radians () function

Python figures Python figures


description

radians () method to convert degrees to radians.


grammar

The following is the syntax radians () method:

import math

math.radians(x)

Note: radians () is not directly accessible, you need to import math module, and then call the method by math static objects.


parameter

  • x - a value.

return value

Returns the value of an angle in radians.


Examples

The following shows an example of using 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)

After running the above example output is:

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

Python figures Python figures