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