Commit 26d49985 authored by BITTU KUMAR's avatar BITTU KUMAR

Adding mysquare to class

parent e803c84b
...@@ -11,7 +11,7 @@ class ComplexNumber: ...@@ -11,7 +11,7 @@ class ComplexNumber:
return "({0}-i{1})".format(comp.x,abs(comp.y)) return "({0}-i{1})".format(comp.x,abs(comp.y))
else: else:
return "({0}+i{1})".format(comp.x,comp.y) return "({0}+i{1})".format(comp.x,comp.y)
def __add__(comp,other): def __add__(comp,other):
...@@ -100,6 +100,8 @@ def conj(comp): ...@@ -100,6 +100,8 @@ 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)
......
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