Definition
The complex() function returns a complex number by specifying a real number and an imaginary number.
Syntax
complex(real, imaginary)
Parameters
| Parameter | Description |
|---|---|
| real | Required. A number representing the real part of the complex number. Default 0. The real number can also be a String, like this '3+5j', when this is the case, the second parameter should be omitted. |
| imaginary | Optional. A number representing the imaginary part of the complex number. Default 0. |
Examples
result = complex(9, 5)
print(result)