``````

In [1]:

c = 3 + 4j

print(c)
print(type(c))

``````
``````

(3+4j)
<class 'complex'>

``````
``````

In [2]:

# c = 3 + j
# NameError: name 'j' is not defined

``````
``````

In [3]:

c = 3 + 1j

print(c)

``````
``````

(3+1j)

``````
``````

In [4]:

c = 3j

print(c)

``````
``````

3j

``````
``````

In [5]:

c = 3 + 0j

print(c)

``````
``````

(3+0j)

``````
``````

In [6]:

c = 1.2e3 + 3j

print(c)

``````
``````

(1200+3j)

``````
``````

In [7]:

c = complex(3, 4)

print(c)
print(type(c))

``````
``````

(3+4j)
<class 'complex'>

``````
``````

In [8]:

c = 3 + 4j

``````
``````

In [9]:

print(c.real)
print(type(c.real))

``````
``````

3.0
<class 'float'>

``````
``````

In [10]:

print(c.imag)
print(type(c.imag))

``````
``````

4.0
<class 'float'>

``````
``````

In [11]:

# c.real = 5.5
# AttributeError: readonly attribute

``````
``````

In [12]:

c = 3 + 4j

print(c.conjugate())

``````
``````

(3-4j)

``````
``````

In [13]:

c = 3 + 4j

print(abs(c))

``````
``````

5.0

``````
``````

In [14]:

c = 1 + 1j

print(abs(c))

``````
``````

1.4142135623730951

``````
``````

In [15]:

c1 = 3 + 4j
c2 = 2 - 1j

``````
``````

In [16]:

print(c1 + c2)

``````
``````

(5+3j)

``````
``````

In [17]:

print(c1 - c2)

``````
``````

(1+5j)

``````
``````

In [18]:

print(c1 * c2)

``````
``````

(10+5j)

``````
``````

In [19]:

print(c1 / c2)

``````
``````

(0.4+2.2j)

``````
``````

In [20]:

print(c1 ** 3)

``````
``````

(-117+44j)

``````
``````

In [21]:

print(c1 + 3)

``````
``````

(6+4j)

``````
``````

In [22]:

print(c1 * 0.5)

``````
``````

(1.5+2j)

``````