Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

numpy
python3
python
communitycreator

How to use the numpy.degrees function in Python

Maria Elijah

The numpy.degrees() function

The numpy.degrees() function in Python is a mathematical function that allows us to convert radians to degrees.

Syntax

numpy.degrees(x,out=None)

Parameters

  • x: This represents the input array in radians.
  • out: This represents where the result is stored.

Return type

The numpy.degrees() function returns the corresponding array with degree values.

Example

The following code shows us how to use the numpy.degrees() function in Python:

# import numpy
import numpy as np
import math 

# create a list
arr = [0, math.pi/2,math.pi/6,8,math.pi/4 ]
print(f"Original array before the np.unwrap(): {arr}")
# compute the degree value for each element and store it
arr_degrees = np.degrees(arr)
print("After the np.degrees()")
print(arr_degrees)
The numpy.degrees function in Python

Explanation

  • Lines 2–3: We import the numpy and math libraries .

  • Line 6: We create a list called arr.

  • Line 7: We display the elements in the list arr.

  • Line 9: We use the np.degrees() function to return the corresponding array with degree values.

  • Lines 10–11: We display the result.

RELATED TAGS

numpy
python3
python
communitycreator
RELATED COURSES

View all Courses

Keep Exploring