Cosine of Degree Values in NumPy
To calculate trigonometric functions such as sine, cosine and tangent in Python we can use functions from the NumPy module such as np.cos(), np.sin() and np.tan().
To get cosine using NumPy our code would be:
import numpy as np
result = np.cos(0.8)
print(result)
0.6967067093471655
Cosine of Degree
To convert angle radians to degrees for use in the cos() function, we can pass it through np.radians() first like this:
import numpy as np
result = np.cos(np.radians(35))
print(result)
0.8191520442889918
An alternative is to use the NumPy deg2rad() function, which might be more readable to you.
import numpy as np
result = np.cos(np.deg2rad(35))
print(result)
0.8191520442889918
