There are three types of numbers in Python: **integer**, **floating numbers,** and **complex numbers**. This article is about “**complex numbers**”. In this article, you will learn what complex number is and how we create complex numbers, and some operations we use in Python with complex numbers.

**Prerequisites:**

Complex numbers are formed as **“a + bi”**. In Python imaginary part of the complex number represented by “**j**” or "**J**". So, “**a + bj**”. “**a**” and “**b**” are real numbers and **“j”** is a solution of equitation. Some examples about where we use complex numbers are an electric circuit which is defined by voltage(V) and current(C), geometry, scientific calculations, and calculus.

Complex numbers represented by "**complex**" command. Like other data types; you do not have to specify complex numbers to Python. Python knows.

Let’s see how complex numbers are written in code.

**Code:**

>>>a = (1+2j)

>>>b = complex(2+4j)

>>>print(type(a))

>>>print(type(b))

**Output:**

<class 'complex'>

<class 'complex'>

Python supports basic aritmetic calculations with complex numbers by default.

**Code:**

>>>a = 1 + 2j

>>>b = 4 + 4j

>>>print(a+b)

>>>print(a-b)

>>>print(a*b)

>>>print(a/b)

**Output:**

(5+6j)

(-3-2j)

(-4+12j)

(0.375+0.125j)

Real numbers (integers and floating numbers), require "**math**" library to be imported to be able to use some aritmetic operations. For complex numbers, we need to import "**cmath**" library to be able to use same operator like real numbers. I am sure you are wondering how are we even importing a library to our software. don´t worry, it is very easy. We use "**import**" command. However, Python doesn’t support comparison operators like **<**,** >**, **<=**, **=>** with complex numbers.

**Code:**

>>>import cmath #Imports cmath library

>>>a = 1 + 2j

>>>b = 4 + 4j

>>>print(cmath.sqrt(a))

>>>print(cmath.sqrt(b))

**Output:**

(1.272019649514069+0.7861513777574233j)

(2.19736822693562+0.9101797211244547j)