In python, you can put ‘j’ or ‘J’ after a number to make it imaginary, so you can write complex literals easily:

>>> 1j
1j
>>> 1J
1j
>>> 1j * 1j
(-1+0j)

The ‘j’ suffix comes from electrical engineering, where the variable ‘i’ is usually used for current. (Reasoning found here.)

The type of a complex number is complex, and you can use the type as a constructor if you prefer:

>>> complex(2,3)
(2+3j)

A complex number has some built-in accessors:

>>> z = 2+3j
>>> z.real
2.0
>>> z.imag
3.0
>>> z.conjugate()
(2-3j)

Several built-in functions support complex numbers:

>>> abs(3 + 4j)
5.0
>>> pow(3 + 4j, 2)
(-7+24j)

The standard module cmath has more functions that handle complex numbers:

>>> import cmath
>>> cmath.sin(2 + 3j)
(9.15449914691143-4.168906959966565j)
Answer from rob mayoff on Stack Overflow
🌐
Python
docs.python.org › 3 › library › cmath.html
cmath — Mathematical functions for complex numbers
The functions in this module accept integers, floating-point numbers or complex numbers as arguments. They will also accept any Python object that has either a __complex__() or a __float__() method: these methods are used to convert the object ...
🌐
Real Python
realpython.com › python-complex-numbers
Simplify Complex Numbers With Python – Real Python
October 21, 2023 - This means you can express mathematical formulas that involve complex numbers with little overhead. Python lets you use complex numbers in arithmetic expressions and call functions on them just like you would with other numbers in Python.
🌐
Python
docs.python.org › 3 › c-api › complex.html
Complex Number Objects — Python 3.14.3 documentation
The C structure which corresponds to the value portion of a Python complex number object. Most of the functions for dealing with complex number objects use structures of this type as input or output values, as appropriate.
🌐
GitHub
hplgit.github.io › primer.html › doc › pub › class › ._class-solarized005.html
Introduction to classes in Python
Suppose we add a complex number and a real number, which is a mathematically perfectly valid operation: ... AttributeError: 'float' object has no attribute 'real' In this case, Python sees u + 4.5 and tries to use u.__add__(4.5), which causes trouble because the other argument in the __add__ method is 4.5, i.e., a float object, and float objects do not contain an attribute with the name real (other.real is used in our __add__ method, and accessing other.real is what causes the error).
🌐
Medium
mike-vincent.medium.com › quarks-outlines-python-complex-numbers-2b1a242fcb70
Quark’s Outlines: Python Complex Numbers | by Mike Vincent | Medium
August 18, 2025 - Python complex numbers support addition, subtraction, multiplication, and division. You can also find the absolute value of a complex number using abs(). Python follows math rules for complex numbers. This makes it easy to use them in scientific and engineering code.
Find elsewhere
🌐
Luis Llamas
luisllamas.es › inicio › cursos › curso python
Complex Numbers in Python
November 20, 2024 - It is possible to access the real ... # Output: 1.0 2.0 ... Python uses the standard representation of complex numbers according to the IEEE 754 standard for double-precision floating-point numbers....
🌐
W3Schools
w3schools.com › python › ref_func_complex.asp
Python complex() Function
Remove List Duplicates Reverse ... Python Certificate Python Training ... The complex() function returns a complex number by specifying a real number and an imaginary number....
🌐
Real Python
realpython.com › lessons › complex-numbers-python
Complex Numbers (Video) – Real Python
You can slap the imaginary unit to either of those two numbers in a complex-number literal to indicate that the imaginary part. When you only have the imaginary numbers in your literal, then Python will add them and create a complex number without the real part, but it’s still a complex number.
Published   October 18, 2022
Top answer
1 of 9
74

It appears to be, as you guessed, because Python follows the electrical engineering convention. Here's an exchange from the Python bug tracker Issue10562:

Boštjan Mejak: In Python, the letter 'j' denotes the imaginary unit. It would be great if we would follow mathematics in this regard and let the imaginary unit be denoted with an 'i'.

Michael Foord: We follow engineering which uses j.

(I was about to close this as wontfix but Antoine is particularly keen that Mark deals with this issue...)

Mark Dickinson: Just to add my own thoughts: 'j' for a (not the ) square root of -1 has, as Michael points out, a history of use in engineering (particularly electrical engineering) and physics. Personally, I would have preferred 'i' to 'j' here, but changing it now would cause (IMO) gratuitous breakage. It really doesn't seem a big enough issue to be worth making a fuss about.

...

Much later:

Guido van Rossum: This will not be fixed. For one thing, the letter 'i' or upper case 'I' look too much like digits. The way numbers are parsed either by the language parser (in source code) or by the built-in functions (int, float, complex) should not be localizable or configurable in any way; that's asking for huge disappointments down the road. If you want to parse complex numbers using 'i' instead of 'j', you have plenty of solutions available already.

2 of 9
21

Python adopted the convention used by electrical engineers. In that field, i is used to represent current and use j as the square root of -1.

There was a bug logged to change it to i in Python 3.3. It was resolves as a "WONTFIX" with this reasoning by Guido van Rossum:

This will not be fixed. For one thing, the letter 'i' or upper case 'I' look too much like digits. The way numbers are parsed either by the language parser (in source code) or by the built-in functions (int, float, complex) should not be localizable or configurable in any way; that's asking for huge disappointments down the road. If you want to parse complex numbers using 'i' instead of 'j', you have plenty of solutions available already.

🌐
Note.nkmk.me
note.nkmk.me › home › python
Complex Numbers in Python | note.nkmk.me
August 10, 2023 - You can also create complex numbers using the constructor, complex(), which takes the real and imaginary parts as arguments. Built-in Functions - complex() — Python 3.11.4 documentation
🌐
Allpython
allpython.in › handling-complex-numbers-in-python
Handling Complex Numbers in Python
March 27, 2023 - Python has a variety of operators ... in Python with some code snippets The division operator (/) in Python performs division of 2 numbers. The numbers can be of the type integer, floating point or complex…....
🌐
AskPython
askpython.com › home › python complex numbers
Python Complex Numbers - AskPython
August 6, 2022 - A Complex Number is any number of the form a + bj, where a and b are real numbers, and j*j = -1. In Python, there are multiple ways to create such a Complex Number.
🌐
B_Jupyter
audiolabs-erlangen.de › resources › MIR › FMP › C2 › C2_ComplexNumbers.html
Complex Numbers
To specify a complex number, one can also use the constructor complex. ... Python offers the built-in math package for basic processing of complex numbers.
🌐
Python Geeks
pythongeeks.org › python geeks › learn python › complex numbers in python
Complex Numbers in Python - Python Geeks
June 21, 2023 - Complex numbers have a real and imaginary part, and can be expressed in the form ‘a+bi’. Python provides built-in support for complex numbers and includes various functions to perform arithmetic operations on them.
🌐
Vultr Docs
docs.vultr.com › python › built-in › complex
Python complex() - Create Complex Number | Vultr Docs
November 22, 2024 - The complex() function in Python is essential for creating complex numbers, which are numbers with both a real and an imaginary component.
🌐
CodeSpeedy
codespeedy.com › home › complex numbers in python
Complex numbers in Python - CodeSpeedy
July 17, 2022 - Complex numbers are the numbers that contain a real part and a complex part, for example ‘2+3j’. We can use complex numbers in python using the ‘cmath’ module that contains mathematical functions for complex numbers.
🌐
Guidetopython
en.guidetopython.com › home › index › complex()
Python complex() - Built-in Function | Guide to Python
Learn Python complex(): Creates a complex number (e.g. 3+4j). Interactive examples, playground, and documentation.
🌐
Spark Code Hub
sparkcodehub.com › python › core › complex-numbers
Mastering Python Complex Numbers: A Comprehensive Guide for Beginners
Complex numbers extend the number system beyond real numbers, allowing solutions to equations like · x² + 1 = 0, which have no real solutions. In programming, they are used for: Solving polynomial equations with imaginary roots. Analyzing alternating current (AC) circuits in electrical engineering. Processing signals in telecommunications and audio engineering. Performing transformations in graphics and physics simulations. Python’s seamless integration of complex numbers makes it a go-to language for these applications.