Python Practice › NumPy Programs › Program 6
Element-wise real test
Write a NumPy program to test element-wise for real numbers.
Input
[2, 4, 6+9j, 7]
Output
[ True True False True]
Approach
np.isreal().
Solution
import numpy as npprint(np.isreal(np.array([2, 4, 6 + 9j, 7])))Output
[ True True False True]
Learn the concept
New to this topic? Read the lesson, then come back.