In [1]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
C = 500E-9;# in Farad
R = 100000;# in Ohm
V = 50;# in VOlts
ti = 0.15;# in sec
tc = 0.08;# in sec
Vrt = 35;# in Volts
#calculation:
#Initial current,
i0 = (V/R)
#when time t = 150ms current is
i150 = (V/R)*math.e**(-1*ti/(R*C))
#capacitor voltage, Vc
Vc = V*(1 - math.e**(-1*tc/(R*C)))
#time, t
tvr = -1*R*C*math.log(Vrt/V)
#Results
print "\n\n Result \n\n"
print "\n initial value of current flowing is ",round(i0*1E3,2),"mA"
print "\n current flowing at t = 150ms is ",round(i150*1E6,2),"uA"
print "\n value of capacitor voltage at t = 80ms is ",round(Vc,2)," V"
print "\n the time after connection when the resistor voltage is 35 V is ",round(tvr*1E3,2),"msec"
```

In [2]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
C = 5E-6;# in Farad
R = 2000000;# in Ohm
V = 200;# in VOlts
tc = 20;# in sec
#calculation:
#capacitor voltage, Vc
Vc = V*(math.e**(-1*tc/(R*C)))
#Results
print "\n\n Result \n\n"
print "\n value of capacitor voltage at t = 20s is ",round(Vc,2)," V"
```

In [3]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
L = 0.05;# in Henry
R = 5;# in Ohm
V = 110;# in VOlts
ti = 0.004;# in sec
tvr = 0.006;# in sec
tvl = 0.006;# in sec
it = 15;# in amperes
#calculation:
#steady state current i
i = V/R
#when time t = 4ms current is
i4 = (V/R)*(1 - math.e**(-1*ti*R/L))
#resistor voltage, VR
VR6 = V*(1 - math.e**(-1*tvr*R/L))
#inductor voltage, VL
VL6 = V*(math.e**(-1*tvl*R/L))
#time, t
ti = (-1*L/R)*math.log(1 - it*R/V)
#Results
print "\n\n Result \n\n"
print "\n steady state current i is ",round(i,2)," A"
print "\n when time t = 4ms current is is ",round(i4,2)," A"
print "\n value of resistor voltage at t = 6ms is ",round(VR6,2)," V"
print "\n value of inductor voltage at t = 6ms is ",round(VL6,2)," V"
print "\n the time after connection when the current is 15 V is ",round(ti,5)," sec"
```

In [4]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
i = 5;# in Amperes
L = 2# in Henry
i1 = 0.2;# in Amperes
R = 10;# in Ohm
#calculation:
#time t
ti = (-1*L/R)*math.log(i1/i)
#voltage across the resistor is a maximum
VRm = i*R
#Results
print "\n\n Result \n\n"
print "\n time t for the current in the 2 H inductor to fall to 200 mA is ",round(ti,3)," sec"
print "\n max voltage across the resistor is ",VRm," V"
```

In [5]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
L = 0.002# in Henry
R = 1000;# in Ohm
C1 = 5E-6;# in farad
C2 = 5E-9;# in farad
#calculation:
a = (R/(2*L))**2
b = 1/(L*C1)
if (a>b):
s1 = "overdamped";
elif (a<b):
s1 = "underdamped";
else:
s1 = "critically damped";
c = 1/(L*C2)
if (a>c):
s2 = "overdamped";
elif (a<c):
s2 = "underdamped";
else:
s2 = "critically damped";
#Results
print "\n\n Result \n\n"
print "\n circuit is ",s1
print "\n if C = 5 nF, circuit is ",s2
```

In [6]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
L = 0.002# in Henry
R = 1000;# in Ohm
#calculation:
a = (R/(2*L))**2
#for critically damped
C = 4*L/R**2
#Results
print "\n\n Result \n\n"
print "\n capacitance C is ",C*1E9,"nF"
```

In [2]:

```
from __future__ import division
import math
import cmath
#initializing the variables:
L = 1.5# in Henry
R = 90;# in Ohm
C = 5*1E-6; # in Farad
V = 10; # in Volts
#calculation:
a = -1*R/(2*L)
b = (1/(L*C) - (R/(2*L))**2)**0.5
V0 = V
I0 = 0
A = V0
B = (I0 - C*a*V0)/(C*b)
#Results
print "\n\n Result \n\n"
print "Current, i = e^(",a,"t) (",round((a*C*B - A*C*b),4),"sin(",round(b,1),"t) + (",round((-1*a*C*A + B*C*C*b),0),"cos(",round(b,1),"t) Amps."
```