imaginary numbers are written with a suffix of "j" or "J" : complex « Data Type « Python Tutorial






Complex numbers with a nonzero real component are written as "(real+imagj)", or can be created with the "complex(real, imag)" function.

print 1j * 1J
print 1j * complex(0,1)
print 3+1j*3
print (3+1j)*3
print (1+2j)/(1+1j)








2.2.complex
2.2.1.import cmath for Complex number
2.2.2.Complex Number Attributes
2.2.3.imaginary numbers are written with a suffix of "j" or "J"
2.2.4.To extract these parts from a complex number z, use z.real and z.imag.
2.2.5.Use abs(z) to get its magnitude (as a float) or z.real to get its real part
2.2.6.Complex Math