when should i use complex number in python code example
Example 1: complex num in python
c = 1 + 2j # or c = complex(1, 2)
print(c) # (1+2j)
print(type(c)) # <class 'complex'>
print(c.real()) # 1.0
print(c.imag()) # 2.0
print(c + complex(3, -5)) # (4-3j)
Example 2: complex numbers python
c = 1 + 2j
print(type(c))
print(c)
c1 = complex(2, 4)
print(type(c1))
print(c1)