Commit 6ec165f7 authored by BITTU KUMAR's avatar BITTU KUMAR

merged elec.

parents d1d692cf f2d1f716
...@@ -8,13 +8,14 @@ class ComplexNumber: ...@@ -8,13 +8,14 @@ class ComplexNumber:
def __str__(comp): def __str__(comp):
if comp.y<0 : if comp.y<0 :
return "({0},{1})".format(comp.x,comp.y) return "({0},{1})".format(comp.x,abs(comp.y))
else: else:
return "({0},{1})".format(comp.x,comp.y) return "({0},{1})".format(comp.x,comp.y)
def __repr__(comp): def __repr__(comp):
return ('str(comp.x)'" + i"'str(comp.y)') 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):
...@@ -106,6 +107,7 @@ def mysquare(comp): ...@@ -106,6 +107,7 @@ def mysquare(comp):
return comp**2 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)
......
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