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

merged elec.

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