Complex Number Attributes : complex « Data Type « Python Tutorial






Attribute          Description
num.real          Real component of complex number num
num.imag          Imaginary component of complex number num
num.conjugate()      Returns complex conjugate of num

aComplex = -8.3 - 1.4j
print aComplex
print aComplex.real
print aComplex.imag
print aComplex.conjugate()








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