ID EN
Built-in Functions

complex

Python 3.11

Return a complex number with the value real + imag*1j or convert a string or number to a complex number. If the first parameter is a string, it will be interpreted as a complex number and the function must be called without a second parameter. The second parameter can never be a string. Each argument may be any numeric type (including complex). If imag is omitted, it defaults to zero and the constructor serves as a numeric conversion like int and float. If both arguments are omitted, returns 0j.

Syntax

PYTHON
class complex(real=0, imag=0)

See Also

int float __complex__() __float__() __index__() ValueError Numeric Types — int float complex __index__()