Commit f2d1f716 authored by BITTU KUMAR's avatar BITTU KUMAR

Adding Elec.

parent 9f519731
...@@ -8,9 +8,12 @@ class ComplexNumber: ...@@ -8,9 +8,12 @@ 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}-j.{1})".format(comp.x,abs(comp.y))
else: else:
return "({0},{1})".format(comp.x,comp.y) return "({0}+j.{1})".format(comp.x,comp.y)
def __repr__(comp):
return ('str(comp.x)'" + i"'str(comp.y)')
...@@ -100,6 +103,10 @@ def conj(comp): ...@@ -100,6 +103,10 @@ 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)
......
from complexno import ComplexNumber
def myexponent(x):
epowx=1
m=1
for i in range(1,100):
m*=x/i
epowx+=m
return epowx
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