# numpy.isrealobj () in Python

NumPy | Python Methods and Functions

Parameters:

`  array:  [array_like] Input array or object whose elements, we need to test. `

Return:

` True, if the input array hasn't any complex element; otherwise False `

Code 1:

 ` # Python program explaining ` ` # isrealobj () function ` ` import ` ` numpy as np `   ` in_array ` ` = ` ` [` ` 1 ` `, ` ` 3 ` `, ` ` 5 ` `, ` ` 4 ` `] ` ` print ` ` (` ` "Input array:" ` `, in_array) `   ` output_value ` ` = ` ` np.isrealobj (in_array) ` ` print ` ` (` ` "Is real:" ` `, output_value) `

Output:

` Input array: [1, 3, 5 , 4] Is real: True `

Code 2:

 ` # Python program illustrating ` ` # numpy.isrealobj () method ` ` import ` ` numpy as geek ` ` `  ` # Returns True / False for each item ` ` a ` ` = ` ` geek.arange (` ` 20 ` `). resh ape (` ` 5 ` `, ` ` 4 ` `) ` ` print ` ` (` `" Is real: "` `, geek.isrealobj (a)) ` ` `  ` # Returns True / False as ANS ` ` # because we mentioned dtpe at the beginning ` ` b ` ` = ` ` geek.arange (` ` 20 ` `). reshape (` ` 5 ` `, ` ` 4 ` `). dtype ` ` = ` ` complex `   ` print ` ` (` `" "` , b) ` print ` ` (` ` "Is real:" ` `, geek.isrealobj (b)) `     ` b ` ` = ` ` [[` ` 1j ` `], ` ` [` ` 3 ` `]] ` ` print ` ` (` ` "Is real: "` `, geek.isrealobj (b)) `

Output:

` Is real: True class 'complex' Is real: True Is real: False `