a | Input array with degree |
out | Optional , ndarray to store result |
where | Optional , array with True to get values and False to leave the value |
import numpy as np
ar_deg=np.array([20,90,120,160,180]) # input array in degree
ar_rad=np.radians(ar_deg)
print(ar_rad) # output in radian
Output
[0.34906585 1.57079633 2.0943951 2.7925268 3.14159265]
import numpy as np
ar_deg=np.array([20,90,120,160,180])
ar_rad=np.radians(ar_deg,dtype=float)
print(ar_rad)
Output
[0.34906585 1.57079633 2.0943951 2.7925268 3.14159265]
import numpy as np
ar_deg=np.array([120,160,180])
ar_where=np.array([True,False,True])
ar_rad=np.radians(ar_deg,where=ar_where)
print(ar_rad)
Output
[2.09439510e+000 7.90505033e-322 3.14159265e+000]
import numpy as np
ar_deg=np.array([120,160,180])
ar_out=np.ones(ar_deg.shape) # array created to store result
ar_rad=np.radians(ar_deg,out=ar_out)
print(ar_rad)
print(ar_out)
# check of both arrays are same or not
print(ar_rad is ar_out) # True
Output
[2.0943951 2.7925268 3.14159265]
[2.0943951 2.7925268 3.14159265]
True
Numpy
rad2deg()
bincount()
arange()
linspace()
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.