Adding arithmetic version

parent 0f57fbc4
......@@ -8,13 +8,11 @@ class ComplexNumber:
def __str__(comp):
if comp.y<0 :
return "({0}-i{1})".format(comp.x,abs(comp.y))
return "({0},{1})".format(comp.x,comp.y)
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):
if (type(other) is ComplexNumber):
......@@ -102,9 +100,6 @@ def conj(comp):
else:
return comp
def mysquare(comp):
return comp**2
def mag(comp):
return (comp.x**2+comp.y**2)**(0.5)
......@@ -113,6 +108,3 @@ 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