In this python numpy program, we will extract all numbers from a given array using NumPy
Steps to solve the program
- Import the numpy library as np.
- Create an array using np.array().
- Extract all numbers from a given array that are greater than a specified number using Indexing and logic.
- Print the output.
import numpy as np
x = np.array([[6, 5],
[10, 9],
[8, 7]])
print("Array: ",x)
print("Values bigger than 7 =", x[x>7])
Output :
Array: [[ 6 5]
[10 9]
[ 8 7]]
Values bigger than 7 = [10 9 8]