degrees() and radians() in Python


The measurements of angles in mathematics are done using these two units of measurement called degree and radian. They are frequently used in math calculations involving angles and need conversion from one value to another. In python we can achieve these conversions using python functions.

degrees() Function

This function takes radian value as parameter and return the equivalent value in degrees. The return is a float value.

Example

 Live Demo

import math
# Printing degree equivalent of radians.
print("1 Radians in Degrees : ",math.degrees(1))
print("20 Radians in Degrees : ",math.degrees(20))
print("180 Radians in Degrees : ",math.degrees(180))

Output

Running the above code gives us the following result −

1 Radians in Degrees : 57.29577951308232
20 Radians in Degrees : 1145.9155902616465
180 Radians in Degrees : 10313.240312354817

radians() Function

This function takes degree value as parameter and return the equivalent value in radians. The return is a float value.

Example

 Live Demo

import math
# Printing radian equivalent of degrees.
print("1 degrees in radian : ",math.radians(1))
print("60 degrees in radian : ",math.radians(60))
print("180 degrees in radian : ",math.radians(180))

Output

Running the above code gives us the following result −

1 degrees in radian : 0.017453292519943295
60 degrees in radian : 1.0471975511965976
180 degrees in radian : 3.141592653589793

Degrees and Radians() using numpy

numpy package also has inbuilt functions which can directlyconver degrees to radian and vice versa. These functions are names deg2rad and rad2deg.

Example

 Live Demo

import numpy as np
# Printing radian equivalent of degrees.
print("1 degrees to radian : ",np.deg2rad(1))
print("1 radian to degree : ",np.rad2deg(1))

Output

Running the above code gives us the following result^−

1 degrees to radian : 0.017453292519943295
1 radian to degree : 57.29577951308232

Updated on: 23-Aug-2019

540 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements