We can use complex() function to convert other types to complex type.
Form-1: complex(x) We can use this function to convert x into complex number with real part x and imaginary part 0.
Eg: 1) complex(10)==>10+0j 2) complex(10.5)===>10.5+0j 3) complex(True)==>1+0j 4) complex(False)==>0j 5) complex("10")==>10+0j 6) complex("10.5")==>10.5+0j 7) complex("ten") 8) ValueError: complex() arg is a malformed string
21 https://www.youtube.com/durgasoftware
Form-2: complex(x,y)
We can use this method to convert x and y into complex number such that x will be real part and y will be imaginary part.
Eg: complex(10, -2) 10-2j complex(True, False) 1+0j