Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- ## 1. np.sin()
- print(np.sin(np.pi/2.))
- #[Output]:
- #1.0
- """In this we are taking an array of angles in degree and calculating the sine of that, so we are converting
- them to radians first"""
- print(np.sin(np.array((0., 30., 45., 60., 90.)) * np.pi / 180. ))
- #[Output]:
- #array([0. , 0.5 , 0.70710678, 0.8660254 , 1. ])
- ## 2. np.cos()
- ## Similarly we can calulate cosine and tan of angles(degrees or radians)
- print(np.cos(np.array((0., 30., 45.)) * np.pi / 180. ))
- #[Output]:
- #array([1. , 0.8660254 , 0.70710678])
- ## 3. deg2rad function for converting degree to radians
- print(np.deg2rad(180))
- #[Output]:
- #3.141592653589793
Add Comment
Please, Sign In to add comment