.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.