Guest User

Untitled

a guest
Feb 17th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. import numpy as np
  2.  
  3. ## 1. np.sin()
  4. print(np.sin(np.pi/2.))
  5.  
  6. #[Output]:
  7. #1.0
  8.  
  9. """In this we are taking an array of angles in degree and calculating the sine of that, so we are converting
  10. them to radians first"""
  11. print(np.sin(np.array((0., 30., 45., 60., 90.)) * np.pi / 180. ))
  12.  
  13. #[Output]:
  14. #array([0. , 0.5 , 0.70710678, 0.8660254 , 1. ])
  15.  
  16.  
  17. ## 2. np.cos()
  18. ## Similarly we can calulate cosine and tan of angles(degrees or radians)
  19. print(np.cos(np.array((0., 30., 45.)) * np.pi / 180. ))
  20.  
  21. #[Output]:
  22. #array([1. , 0.8660254 , 0.70710678])
  23.  
  24.  
  25. ## 3. deg2rad function for converting degree to radians
  26. print(np.deg2rad(180))
  27.  
  28. #[Output]:
  29. #3.141592653589793
Add Comment
Please, Sign In to add comment