Classes: Dealing with Complex Numbers

  • + 0 comments
    def __add__(self, no):
        return Complex(self.real+no.real,self.imaginary+no.imaginary)
    def __sub__(self, no):
        return Complex(self.real-no.real,self.imaginary-no.imaginary)
    
    def __mul__(self, no):
        a=complex(self.real,self.imaginary)
        b=complex(no.real,no.imaginary)
        c=a*b
        r=c.real
        i=c.imag
        return Complex(r,i)
    def __truediv__(self, no):
         a=complex(self.real,self.imaginary)
         b=complex(no.real,no.imaginary)
         c=a/b
         i=c.imag
         r=c.real
         return Complex(r,i)
    
    def mod(self):
        return Complex(math.sqrt(self.real**2 + self.imaginary**2), 0)
    
    
    
    
    
    
        if self.ima "%   d = map(float, input().split())
    x