Test element-wise for real numbers of a given array using NumPy.

In this python numpy program, we will test element-wise for real numbers of a given array using NumPy.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create an array using np.array().
  3. Test element-wise for real numbers of a given array using np.isreal().
  4. Print the output.
				
					import numpy as np
x = np.array([2,4,6+9j,7])

print(np.isreal(x))
				
			

Output :

				
					[ True  True False  True]
				
			

test element-wise for complex numbers of a given array.

test whether a number is scalar or not.

Leave a Comment