Python complex() class

The complex() class in Python returns a complex number or converts a string or number to a complex number.

Syntax

Parameter

Real: This parameter consists of a number representing the real part of the complex number. By default, its value is 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: It is an optional parameter which consists of a number representing the imaginary part of the complex number

Return

It returns a complex number by specifying a real number and an imaginary number.

Example 1

Output

Example 2

Output

Example 3

Output

 

 

Pin It on Pinterest

Share This