Adding arithmetic version

parent 0f57fbc4
...@@ -8,13 +8,11 @@ class ComplexNumber: ...@@ -8,13 +8,11 @@ class ComplexNumber:
def __str__(comp): def __str__(comp):
if comp.y<0 : if comp.y<0 :
return "({0}-i{1})".format(comp.x,abs(comp.y)) return "({0},{1})".format(comp.x,comp.y)
else: else:
return "({0}+i{1})".format(comp.x,comp.y) return "({0},{1})".format(comp.x,comp.y)
def __repr__(comp):
return ('str(comp.x)'" + i"'str(comp.y)')
def __add__(comp,other): def __add__(comp,other):
if (type(other) is ComplexNumber): if (type(other) is ComplexNumber):
...@@ -102,9 +100,6 @@ def conj(comp): ...@@ -102,9 +100,6 @@ def conj(comp):
else: else:
return comp return comp
def mysquare(comp):
return comp**2
def mag(comp): def mag(comp):
return (comp.x**2+comp.y**2)**(0.5) return (comp.x**2+comp.y**2)**(0.5)
...@@ -112,7 +107,4 @@ def mag(comp): ...@@ -112,7 +107,4 @@ def mag(comp):
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment