.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 degrees
radNum = 4
result = 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 degrees
radArray = [np.pi/2, np.pi/6, 5, 8]
result = np.degrees(radArray)
print(result)

Note: np.pi represents the mathematical constant approximately equal to 3.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:

Code
Output
Loading...

All contributors

Looking to contribute?

Learn Python:NumPy on Codecademy