Skip to main content
A built-in numeric data type in Python used to represent complex numbers, consisting of a real part and an imaginary part. Both components are stored internally as 64-bit IEEE 754 double-precision floating-point numbers (float).

Instantiation

Complex numbers can be instantiated using literal syntax or the built-in complex() constructor. Python uses the suffix j or J to denote the imaginary unit (equivalent to i in mathematics).

Attributes and Built-in Functions

The complex type exposes the real and imaginary components as read-only attributes, provides a built-in method for mathematical conjugation, and integrates with Python’s standard abs() function to calculate the modulus.

Arithmetic Operations

Complex numbers support standard arithmetic operations, which follow standard algebraic rules for complex arithmetic.

Type Constraints and Exceptions

Because the complex plane lacks a natural linear ordering, complex objects do not support relational comparison operators. Furthermore, operations that imply a scalar continuum or remainder logic are explicitly disabled.

Standard Library Integration

While the built-in math module only supports scalar floats and will raise a TypeError if passed a complex number, Python provides the cmath module specifically for complex mathematical functions.
Tired of Poor Python Skills? Fix That With Deep Grasping!Learn More