Latest web development tutorials

Python3 degrees () function

Python3 digital Python3 digital


description

degrees () Converts radians to degrees.


grammar

The following is the syntax degrees () method:

import math

math.degrees(x)

Note: degrees () 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 angle.


Examples

The following shows an example of using degrees () method:

#!/usr/bin/python3
import math

print ("degrees(3) : ",  math.degrees(3))
print ("degrees(-3) : ",  math.degrees(-3))
print ("degrees(0) : ",  math.degrees(0))
print ("degrees(math.pi) : ",  math.degrees(math.pi))
print ("degrees(math.pi/2) : ",  math.degrees(math.pi/2))
print ("degrees(math.pi/4) : ",  math.degrees(math.pi/4))

After running the above example output is:

degrees(3) :  171.88733853924697
degrees(-3) :  -171.88733853924697
degrees(0) :  0.0
degrees(math.pi) :  180.0
degrees(math.pi/2) :  90.0
degrees(math.pi/4) :  45.0

Python3 digital Python3 digital