Home >>Python Built-in Functions >Python complex() Function
Python complex() function in Python is used to return a complex number by specifying a real number or string. This function contains two parameters, the first parameter is called a real and second as imaginary parts.
Syntax:
complex(real,imaginary)
Parameter | Description |
---|---|
real | It is a Required numeric parameter. It represents the real part of the complex number and its default value is 0. |
imaginary | It is an Optional parameter. It represents the imaginary part of the complex number and its default value is 0. |
Here is an Example
a = complex(7,12) print(a)
Example 2
x = complex(3.7) y = complex(2.3,72.8) print(x) print(y)