To create a complex number from a real part and a complex
part R:
I
complex(R,I)
Both arguments are optional.
With two arguments, both arguments must be numbers of any numeric type.
With one numeric argument, it returns a complex number
with real part and an imaginary part of zero.
R
To convert a complex number in string form, pass that
string as the only argument. If the string is not a valid
complex number, the function raises a ValueError exception.
If called with no arguments, it returns a complex zero.
Examples:
>>> complex(-4.04, 3.173) (-4.04+3.173j) >>> complex(-4.04) (-4.04+0j) >>> complex() 0j >>> c1=4+5j >>> c2=6+7j >>> complex(c1, c2) # Equals (4+5j)+(6+7j)j = 4+5j+6j-7 (-3+11j) >>> c1 + c2*1.0j (-3+11j)