Skip to content
Related Articles

Related Articles

numpy.imag() function – Python
  • Last Updated : 11 Jun, 2020

numpy.imag() function return the imaginary part of the complex argument.

Syntax : numpy.imag(arr)

Parameters :
arr : [array_like] Input array.

Return : [ndarray or scalar] The imaginary component of the complex argument. If val is real, the type of val is used for the output. If val has complex elements, the returned type is float.

Code #1 :






# Python program explaining
# numpy.imag() function
       
# importing numpy as geek 
import numpy as geek 
   
arr = geek.array([1 + 3j, 5 + 7j, 9 + 11j])
   
gfg = arr.imag
   
print (gfg)

Output :

[ 3.  7. 11.]

 
Code #2 :




# Python program explaining
# numpy.imag() function
       
# importing numpy as geek 
import numpy as geek 
   
arr = geek.array([2 + 3j, 5 + 6j, 8 + 9j])
   
gfg = arr.imag
   
print (gfg)

Output :

[3. 6. 9.]

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :