Advertisement
Guest User

newfile.py

a guest
Aug 5th, 2023
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. import numpy as np
  2.  
  3. # Create a NumPy array
  4. data = [1, 2, 3, 4, 5]
  5. my_array = np.array(data)
  6.  
  7. # Print the array
  8. print("Original array:", my_array)
  9.  
  10. # Perform some basic operations
  11. print("Sum of array elements:", np.sum(my_array))
  12. print("Mean of array elements:", np.mean(my_array))
  13. print("Maximum value in the array:", np.max(my_array))
  14. print("Minimum value in the array:", np.min(my_array))
  15.  
  16. # Create a new array with square of elements
  17. squared_array = my_array ** 2
  18. print("Squared array:", squared_array)
  19.  
  20. # Create a new array with elements greater than 3
  21. filtered_array = my_array[my_array > 3]
  22. print("Elements greater than 3:", filtered_array)
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement