You are viewing a single comment's thread. Return to all comments →
class Complex(complex): def __add__(s,o): return Complex(complex(s)+complex(o)) def __sub__(s,o): return Complex(complex(s)-complex(o)) def __mul__(s,o): return Complex(complex(s)*complex(o)) def __truediv__(s,o): return Complex(complex(s)/complex(o)) def mod(self): return Complex(abs(self)) def __str__(self): return "%.2f%+.2fi" % (self.real,self.imag)
works well in all test cases except one: it gives wrong result for testcase 5. What can that be?
Seems like cookies are disabled on this browser, please enable them to open this website
Classes: Dealing with Complex Numbers
You are viewing a single comment's thread. Return to all comments →
works well in all test cases except one: it gives wrong result for testcase 5. What can that be?