Python Practice › NumPy Programs › Program 48
Numbers greater than a value
Write a NumPy program to extract numbers greater than 6.
Input
[[6, 5], [10, 9], [7, 8]]
Output
[10 9 7 8]
Approach
- A boolean mask.
Solution
import numpy as npa = np.array([[6, 5], [10, 9], [7, 8]])print(a[a > 6])Output
[10 9 7 8]
Learn the concept
New to this topic? Read the lesson, then come back.