Python program for multiplication and division of complex number

Given two complex numbers. The task is to multiply and divide them.

Multiplication of complex number: In Python complex numbers can be multiplied using * operator

Examples:

Input: 2+3i, 4+5i 
Output: Multiplication is : (-7+22j) 

Input: 2+3i, 1+2i
Output: Multiplication is : (-4+7j) 
filter_none

edit
close

play_arrow

link
brightness_4
code

# Python program to demonstrate
# multiplication of complex numbers
  
  
def mulComplex( z1, z2):
    return z1*z2
   
      
# driver code
z1 = complex(2, 3)
z2 = complex(4, 5)
  
  
print("Multiplication is :", mulComplex(z1,z2))

chevron_right


Output:

Multiplication is : (-7+22j)

Division of complex number: In Python, complex numbers can be divided using the / operator.

Examples:

Input: 2+3i, 4+5i
Output: Division  is : (0.5609756097560976+0.0487804878048781j)

Input: 2+3i, 1+2i
Output: Division is :(1.6-0.2j) 
filter_none

edit
close

play_arrow

link
brightness_4
code

# Python program to demonstrate
# division of complex numbers
  
  
def divComplex( z1, z2):
    return z1 / z2
  
# driver code
  
z1 = complex(2, 3)
z2 = complex(4, 5)
  
print( "Division is :", (divComplex(z1, z2))

chevron_right


Output:

Division is : (0.5609756097560976+0.0487804878048781j)
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.