Python complex() Function Syntax
Syntax: complex ([real[, imaginary]])
- real [optional]: numeric type (including complex). It defaults to zero.
- imaginary [optional]: numeric type (including complex) .It defaults to zero.
Return: Returns a complex number in the form of (real + imaginary) example (5+2j)
Note: If the first parameter that passed is a string then the second parameter shouldn’t be passed else will raise a TypeError. The string must not contain whitespace around the + or – operator else it will raise ValueError in Python.
Python complex() Function
Python complex() function returns a complex number ( real + imaginary) example (5+2j) when real and imaginary parts are passed, or it also converts a string to a complex number.