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)

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.

Examples:

complex()
//0j
complex(4)
//4+0j
complex(3, 4)
//(3+4j)
complex(2, -3)
//(2-3j)
complex(2.3, 1.5)
//(2.3+1.5j)
complex('-2')
//(-2+0j)