Advertisement
Guest User

Untitled

a guest
Dec 23rd, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. import numpy as np
  2.  
  3. a = np.zeros((5, 5))
  4.  
  5. count = 1
  6. for i in range(5):
  7.     for j in range(5):
  8.         a[i][j] = count
  9.         count += 1
  10. print(a)
  11. print()
  12.  
  13. indices = np.nonzero((a % 3 == 0) & (a % 5 != 0))
  14.  
  15. print(a[indices])
  16.  
  17.  
  18. print("\nAlso Desired:")
  19. print("[ 4. 7. 13. 19. 21. 25.]")
  20. print("Using a[indices] of some form")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement