Home >>Python Built-in Functions >Python complex() Function

Python complex() Function

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 Values

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)
Output:
(7+12j)

Example 2

x = complex(3.7) y = complex(2.3,72.8) print(x) print(y)
Output:
(3.7+0j) (2.3+72.8j)

Python Built-in Functions Python abs() Function Python all() Function Python any() Function Python ascii() Function Python bin() Function Python bool() Function Python bytearray() Function Python bytes() Function Python callable() Function Python chr() Function Python compile() Function Python complex() Function Python delattr() Function Python dict() Function Python dir() Function Python divmod() Function Python enumerate() Function Python eval() Function Python exec() Function Python filter() Function Python float() Function Python format() Function Python frozenset() Function Python getattr() Function Python globals() Function Python hasattr() Function Python hash() Function Python help() Function Python hex() Function Python id() Function Python input() Function Python int() Function Python isinstance() Function Python issubclass() Function Python iter() Function Python len() Function Python list() Function Python locals() Function Python map() Function Python max() Function Python memoryview() Function Python min() Function Python next() Function Python object() Function Python oct() Function Python open() Function Python ord() Function Python pow() Function Python print() Function Python property() function Python range() Function Python repr() Function Python reversed() Function Python round() Function Python set() Function Python setattr() Function Python slice() Function Python sorted() Function Python str() Function Python sum() Function Python super() Function Python tuple() Function Python type() Function Python vars() Function Python zip() Function
No Sidebar ads