Write a NumPy program to convert angles from degrees to radians for all elements in a given array.
Sample Input: Input: [-180., -90., 90., 180.]
import numpy as np x = np.array([-180., -90., 90., 180.]) r1 = np.radians(x) r2 = np.deg2rad(x) assert np.array_equiv(r1, r2) print(r1)
Sample Output:
[-3.14159265 -1.57079633 1.57079633 3.14159265]
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer