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
| Name | Description |
|---|---|
| real | The real part, or a string representing a complex number. |
| imag | The 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)