Saturday, October 18, 2025
HomeLanguagesnumpy.imag() function – Python

numpy.imag() function – Python

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.]
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS