# Python complex number - "j" or "J" is the imaginary unit in Python

Python complex number is expressed with j, which is the imaginary unit or unit imaginary number.

a = 5 + 12j
b = complex(5, 12)

print(a)  # (5+12j)
print(b)  # (5+12j)

print(type(a))  # <class 'complex'>
print(type(b))  # <class 'complex'>


The imaginary unit is expressed i in normal math textbooks but Python uses j or J.

a = 5 + 12J

print(a)  # (5+12j)
print(type(a))  # <class 'complex'>


## Only j raises NameError

j should be a suffix of number so only j means nothing and raises NameError.

a = j

# NameError: name 'j' is not defined


So 1j can't be simplified.

a = 1j
b = 3 + 1j

print(a)  # 1j
print(b)  # (3+1j)