Next / Previous / Contents / TCC Help System / NM Tech homepage

20.9. complex(): Convert to complex type

To create a complex number from a real part R and a complex part I:

complex(R, I)

Both arguments are optional.

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)