September 2026
1051 pages
35h 4m
English
Surprisingly, there is a data type for storing complex numbers among the basic data types of Python. In many programming languages, complex numbers would be more of a side note in the standard library or left out altogether. If you aren’t familiar with complex numbers, you can safely skip this section. It doesn’t cover anything that would be required for further learning Python.
Complex numbers consist of a real part and an imaginary part. The imaginary part is a real number multiplied by the imaginary unit j.[ 44 ] The imaginary unit j is defined as the solution of the following equation:
j2 = –1
In the following example, we assign the name v to a complex number:
v = 4j
If you specify only an imaginary part, ...
Read now
Unlock full access