Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python degrees() function

Python degrees() function

Python Numbers Python Numbers


Description

degrees() Converts radians to degrees.


Syntax

The syntax of the degrees() method is as follows:



import math



math.degrees(x)

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


Parameters


Return Value

Returns a value in degrees.


Example

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

Running the example above produces:



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 Numbers Python Numbers