.degrees()
Published Jun 29, 2024
Contribute to Docs
In NumPy, the .degrees()
function converts angles expressed in radians into degrees.
Syntax
numpy.degrees(x, out=None, where=True)
x
: The number or array of numbers in radians that must be converted.out
: An optional parameter specifying where the result is stored.where
: An optional parameter specifying a condition to filter which elements to convert.
Example 1
# Importing the 'numpy' library as 'np'import numpy as np# Convert a single number from radians to degreesradNum = 4result = np.degrees(radNum)print(result)
Below is the output generated by the above code snippet:
229.1831180523293
Example 2
# Importing the 'numpy' library as 'np'import numpy as np# Convert an array of numbers from radians to degreesradArray = [np.pi/2, np.pi/6, 5, 8]result = np.degrees(radArray)print(result)
Note:
np.pi
represents the mathematical constant approximately equal to3.141592653589793
.
The output generated by the above code snippet is as follows:
[ 90. 30. 286.47889757 458.3662361 ]
Codebyte Example
Experiment with the .degrees()
function using the Codebyte below:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Python:NumPy on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Skill path
Data Science Foundations
Learn to clean, analyze, and visualize data with Python and SQL.Includes 15 CoursesWith CertificateBeginner Friendly54 hours - Career path
Data Scientist: Machine Learning Specialist
Machine Learning Data Scientists solve problems at scale, make predictions, find patterns, and more! They use Python, SQL, and algorithms.Includes 27 CoursesWith Professional CertificationBeginner Friendly90 hours - Course
Learn Python 3
Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.With CertificateBeginner Friendly23 hours