
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
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
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
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
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
- Related Articles
- Convert angles from degrees to radians in Python
- Convert angles from radians to degrees with Python rad2deg()
- Convert angles from degrees to radians with Python deg2rad()
- Return the angle of the complex argument in radians in Python
- How to set the Y-axis in radians in a Python plot?
- Convert a radian array to degrees in Python
- Is angular displacement is measured in radians?
- Return the angle of the complex argument in degrees in Python
- Program to rotate square matrix by 90 degrees counterclockwise in Python
- How to Convert Decimal Degrees to Degrees Minutes Seconds in Excel
- How to convert Trigonometric Angles in Radians using C#?
- Is PHP deg2rad() equal to MySQL radians()?
- Check whether given degrees of vertices represent a Graph or Tree in Python
- Get the Trigonometric sines of an array of angles given in degrees in Python
- Get the Trigonometric cosine of an array of angles given in degrees with Python
