Python 2
Python 2
A complex number is created from real numbers. Python complex number can be
created either using direct assignment statement or by using complex () function.
Complex numbers which are mostly used where we are using two real numbers. For
instance, an electric circuit which is defined by voltage(V) and current(C) are used in
geometry, scientific calculations and calculus.
Syntax
complex([real[, imag]])
Creating a simple complex number in python
>>> c = 3 +6j
>>> print(type(c))
<class 'complex'>
>>> print(c)
(3+6j)
>>>
>>> c1 = complex(3,6)
>>> print(type(c1))
<class 'complex'>
>>> print(c1)
(3+6j)
From above results, we can see python complex numbers are of type complex. Each
complex number consist of one real part and one imaginary part.
Python Complex Numbers- Attributes and Functions
>>> c = (3 + 6j)
>>>
>>>
>>>
>>> #Conjugate of complex number
>>> c1 = 3 + 6j
>>> c2 = 6 + 15j
>>>
>>> #Addition
>>>
>>> #Subtraction
>>>
>>> #Multiplication
>>>
>>> #Division