# Convert given Complex Numbers into polar form and perform all arithmetic operations

import math

def get_polar_form(z):

re, im = z

r = (re * re + im * im) ** 0.5

if r:

theta = math.asin(im / r)

return (r, theta)

else:

return (0, 0)

def Addition(z1, z2):

r1, theta1 = z1

r2, theta2 = z2

a = r1 * math.cos(theta1) + r2 * math.cos(theta2)

b = r1 * math.sin(theta1) + r2 * math.sin(theta2)

return get_polar_form((a, b))

def Subtraction(z1, z2):

r1, theta1 = z1

r2, theta2 = z2

a = r1 * math.cos(theta1) – r2 * math.cos(theta2)

b = r1 * math.sin(theta1) – r2 * math.sin(theta2)

return get_polar_form((a, b))

def Multiplication(z1, z2):

r1, theta1 = z1

r2, theta2 = z2

return (r1 * r2, theta1 + theta2)

def Division(z1, z2):

r1, theta1 = z1

r2, theta2 = z2

return (r1 / r2, theta1-theta2)

if __name__ == “__main__”:

z1 = (2, 3)

z2 = (4, 6)

z1_polar = get_polar_form(z1)

z2_polar = get_polar_form(z2)

print(“Polar form of the first”)

print(“Complex Number: “, z1_polar)

print(“Polar form of the Second”)

print(“Complex Number: “, z2_polar)

print(“Addition of two complex”)

print(“Numbers: “, Addition(z1_polar, z2_polar))

print(“Subtraction of two “)

print(“complex Numbers: “,

Subtraction(z1_polar, z2_polar))

print(“Multiplication of two “)

print(“Complex Numbers: “,

Multiplication(z1_polar, z2_polar))

print(“Division of two complex “)

print(“Numbers: “, Division(z1_polar, z2_polar))