Trigonometry and Constants
sin, cos, tan, pi and degrees work on arrays in radians.
Example
x = np.array([0, np.pi / 2, np.pi])
print(np.sin(x).round(2), np.cos(x).round(2))
print(np.degrees(np.pi), round(float(np.radians(180)), 3), round(float(np.e), 3))Result
[0. 1. 0.] [ 1. 0. -1.] 180.0 3.142 2.718
Exercise
Pi constant.
np.Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.