Skip to content
Built-in Functions

complex()

Create a complex number.

complex(real=0, imag=0)

complex() creates a number with a real part and an imaginary part. Python writes the imaginary unit with j.

Parameters

NameDescription
realThe real part, or a string representing a complex number.
imagThe imaginary part when real is numeric.

Returns

A complex number.

Try it

Run it and change it
real_part = 2
number = complex(real_part, 3)
print(number)

Related entries