- imag() is a python complex function which are used to get a imaginary part of the complex number.
- complex number is made up of real and imaginary part.
Syntax-
complex.imag
Example-
complex number is n=1+2j
then n.imag will return 2
complex number is n=3+2j
then n.imag will return 2
program-
n=complex(3,2)
print("Complex number is ",n)
print("imaginary part is ",n.imag)
n=complex(1,3)
print("Complex number is ",n)
print("imaginary part is ",n.imag)
n=complex(0,1)
print("Complex number is ",n)
print("imaginary part is ",n.imag)
n=complex(-1,0)
print("Complex number is ",n)
print("imaginary part is ",n.imag)
Complex number is (3+2j)
imaginary part is 2.0
Complex number is (1+3j)
imaginary part is 3.0
Complex number is 1j
imaginary part is 1.0
Complex number is (-1+0j)
imaginary part is 0.0