Latest web development tutorials

Python3 radians () function

Python3 digital Python3 digital


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/python3
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.05235987755982989
radians(-3) :  -0.05235987755982989
radians(0) :  0.0
radians(math.pi) :  0.05483113556160755
radians(math.pi/2) :  0.027415567780803774
radians(math.pi/4) :  0.013707783890401887

Python3 digital Python3 digital