Q:

Write a NumPy program to convert angles from radians to degrees for all elements in a given array

0

Write a NumPy program to convert angles from radians to degrees for all elements in a given array.

Sample Input: [-np.pi, -np.pi/2, np.pi/2, np.pi]

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
x = np.array([-np.pi, -np.pi/2, np.pi/2, np.pi])
r1 = np.degrees(x)
r2 = np.rad2deg(x)
assert np.array_equiv(r1, r2)
print(r1)

Sample Output:

[-180.  -90.   90.  180.]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now