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.
Arguments
Parameters
| Name | Description |
|---|---|
| real | The real part, or a string representing a complex number. |
| imag | The imaginary part when real is numeric. |
Result
Returns
A complex number.
Run it
Try it
Run it and change it
real_part = 2 number = complex(real_part, 3) print(number)
Output
Press Run to see what it prints.