Write a NumPy program to compute the trigonometric sine, cosine and tangent array of angles given in degrees

  • برمجة بايثون

Write a NumPy program to compute the trigonometric sine, cosine and tangent array of angles given in degrees.

الأجوبة

import numpy as np
print("sine: array of angles given in degrees")
print(np.sin(np.array((0., 30., 45., 60., 90.)) * np.pi / 180.))
print("cosine: array of angles given in degrees")
print(np.cos(np.array((0., 30., 45., 60., 90.)) * np.pi / 180.))
print("tangent: array of angles given in degrees")
print(np.tan(np.array((0., 30., 45., 60., 90.)) * np.pi / 180.))

Sample Output:

sine: array of angles given in degrees                                 
[ 0.          0.5         0.70710678  0.8660254   1.        ]          
cosine: array of angles given in degrees                               
[  1.00000000e+00   8.66025404e-01   7.07106781e-01   5.00000000e-01   
   6.12323400e-17]                                                     
tangent: array of angles given in degrees                              
[  0.00000000e+00   5.77350269e-01   1.00000000e+00   1.73205081e+00   
   1.63312394e+16]
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...