In [1]:

```
from __future__ import division
import math
u0=4*math.pi*10**-7 #in weber/amp-m Mu-not=u0
N=10**3 #no.of turns
a=5*10**-2 #im meter
b=10*10**-2 #in meter
h=1*10**-2 #in metre
L=(u0*N**2*h)/(2*math.pi)*math.log(b/a)
print("Inductance of a toroid of recyangular cross section in henry is %.7f"%L)
```

In [2]:

```
from __future__ import division
import math
L=50 #inductance in henry
R=30 #resistance in ohms
t0=math.log(2)*(L/R)
print("Time taken for the current to reach one-half of its final equilibrium in sec is %.7f"%t0)
```

In [3]:

```
from __future__ import division
L=5 #inductance in henry
V=100 #emf in volts
R=20 #resistance in ohms
i=V/R
print("Maximum current in amp is",i)
U=(L*i**2)/2
print("Energy stored in the magnetic field in joules is %.1f"%U)
```

In [4]:

```
from __future__ import division
import math
L=3 #inductance in henry
R=10 #resistance in ohm
V=3 #emf in volts
t=0.30 #in sec
T=0.30 #inductive time constant in sec
#(a)
i=(V/R)*(1-math.exp(-t/T))
P1=V*i
print("The rate at which energy is delivred by the battery in watt is %.7f"%P1)
#(b)
P2=i**2*R
print("The rate at which energy appears as Joule heat in the resistor in watt is %.7f"%P2)
#(c)
print("Let D=di/dt")
D=(V/L)*math.exp(-t/T) #in amp/sec
P3=L*i*D
print("The desired rate at which energy is being stored in the magnetic field in watt is %.7f"%P3)
```

In [5]:

```
from __future__ import division
import math
epsilon0=8.9*10**-12 #in coul2/nt-m2
E=10**5 #elelctric field in volts/meter
B=1 #magnetic field in weber/meter2
u0=4*math.pi*10**-7 #in weber/amp-m Mu-not=u0
a=0.1 #side of the cube in meter
V0=a**3 #volume of the cube in meter3
#(a)
U1=epsilon0*E**2*V0/2 #in elelctric field
print("(a)Energy required to set up in the given cube on edge in electric field in joules is %.7f"%U1)
#(b)
U2=(B**2/(2*u0))*V0
print("(b)Energy required to set up in the given cube on edge in magnetic field in joules is %.3f"%U2)
```