Python Tutorial

Here you can learn about the basics of Python for free.

Thursday, July 2, 2020

Complex Numbers














A Complex number is a number of A+Bi where i is the imaginary number, equal to the square root of -1 i.e.,  -1 and A and B are real numbers.

If we have complex number z, where z=a+bi then a would be real component and b would be imaginary component  of z.

e.g, real component of z=4+3i is  and the  imaginary component  would be 3.

Complex Number in Python: 

Python represent complex number in the form of A+Bj , where it's meaning is same as explained above i.e., j=  -1

Example:
a=0+3.1j
b=1.5+2j

so a has real component as 0 and imaginary as 3.1 

Python displays complex numbers in parentheses when they have a nonzero real part.

Example :



















>>You can retrieve the two components of complex number by using attributes reference:
(a) z.real gives the real part.
(b) z.imag gives imaginary part as a float, not as a complex number.

For example,