Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- # Create a NumPy array
- data = [1, 2, 3, 4, 5]
- my_array = np.array(data)
- # Print the array
- print("Original array:", my_array)
- # Perform some basic operations
- print("Sum of array elements:", np.sum(my_array))
- print("Mean of array elements:", np.mean(my_array))
- print("Maximum value in the array:", np.max(my_array))
- print("Minimum value in the array:", np.min(my_array))
- # Create a new array with square of elements
- squared_array = my_array ** 2
- print("Squared array:", squared_array)
- # Create a new array with elements greater than 3
- filtered_array = my_array[my_array > 3]
- print("Elements greater than 3:", filtered_array)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement