In this python numpy program, we will test element-wise for complex numbers of a given array using NumPy.
Steps to solve the program
- Import the numpy library as np.
- Create an array using np.array()
- Test element-wise for complex numbers of a given array using np.iscomplex().
- Print the output.
import numpy as np
x = np.array([2,4,6+9j,7])
print(np.iscomplex(x))
Output :
[False False True False]