The degrees() method in Python number converts the angle x from radians into degrees. This function belongs to the math module of Python and the value of x here can be a number or any other valid numerical expression. In case the number argument stands out to be a positive or negative number, then the degrees function in the Python number method returns the output else it returns TypeError.
Here is the syntax for degrees() method:
degrees(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 a degree value of an angle.
The example below shows the usage of the degrees() method.
#!/usr/bin/python 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)
When the above program is run, it produces the following result:
degrees(3) : 171.887338539 degrees(-3) : -171.887338539 degrees(0) : 0.0 degrees(math.pi) : 180.0 degrees(math.pi/2) : 90.0 degrees(math.pi/4) : 45.0
Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.