numpy.degrees()
functionThe numpy.degrees()
function in Python is a mathematical function that allows us to convert radians to degrees.
numpy.degrees(x,out=None)
x
: This represents the input array in radians.out
: This represents where the result is stored.The numpy.degrees()
function returns the corresponding array with degree values.
The following code shows us how to use the numpy.degrees()
function in Python:
# import numpyimport numpy as npimport math# create a listarr = [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 itarr_degrees = np.degrees(arr)print("After the np.degrees()")print(arr_degrees)
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
CONTRIBUTOR