Python degrees() Function

Python 数字Python Numbers


Description

degrees()Converts radians to degrees.


Syntax

The following is the syntax of the degrees() method:

import math

math.degrees(x)

Note:degrees() cannot be accessed directly; you need to import the math module, and then call this method through the math static object.


Parameters

  • x -- A numeric value.

Return Value

Returns an angle value.


Examples

The following example demonstrates the use 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)

After running the above example, the output result is:

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

Python 数字Python Numbers

Other Extensions