Question: Create a Complex class to perform the processing. Use the following code template. import math class Complex(object): def __init__(self, real, imaginary): self.real = real self.imaginary

Create a Complex class to perform the processing. Use the following code template.

import math

class Complex(object): def __init__(self, real, imaginary): self.real = real self.imaginary = imaginary

def __add__(self, no): # enter your code here return Complex(real, imaginary)

def __sub__(self, no): # enter your code here return Complex(real, imaginary)

def __mul__(self, no): # enter your code here return Complex(real, imaginary)

def __div__(self, no): # enter your code here return Complex(real, imaginary)

def mod(self): # enter your code here return Complex(real, 0)

def __str__(self): # enter your code here return result

# put this code in a main method C = map(float, raw_input().split()) D = map(float, raw_input().split()) x = Complex(*C) y = Complex(*D) print ' '.join(map(str, [x+y, x-y, x*y, x/y, x.mod(), y.mod()]))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!