The complex() function is used to construct a complex number from two values representing the real parts and the imaginary part. If it is called without any argument, it returns the complex number 0j

A complex number is a number that can be written in the form a + bi where a and b are real numbers and i is the imaginary unit, that satisfies the equation i^2= -1. In Python, is used in place of i.

Syntax:
complex(a, b=0)
copy

Wherecan be an integer, a float, a string, or another complex number.  If a is a string, the second argument is not included.

If b is not given, the integer is used.

ExampleEdit & Run
print( complex() )

print( complex(4) )

print( complex(3, 4) )

print( complex(2, -3) )

print( complex(2.3, 1.5) )

print( complex('-2') )
copy
Output:
0j (4+0j) (3+4j) (2-3j) (2.3+1.5j) (-2+0j) [Finished in 0.010494853369891644s]