In [1]:

```
from __future__ import division
import math
#initializing the variables:
Iab = 50;# in ampere
Ibc = 20;# in ampere
Iec = 15;# in ampere
Idf = 120;# in ampere
Ifg = 40;# in ampere
Iab = 50;# in ampere
I = 2;# in ampere
V1 = 4;# in volts
V2 = 3;# in volts
V3 = 6;# in volts
R1 = 1;# in ohms
R2 = 2;# in ohms
R3 = 2.5;# in ohms
R4 = 1.5;# in ohms
#calculation:
I1 = Iab - Ibc
I2 = Ibc + Iec
I3 = I1 - Idf
I4 = Iec - I3
I5 = Idf - Ifg
# Applying Kirchhoff’s voltage law and moving clockwise around the loop of Figure 13.3(b) starting at point A:
E = I*R2 + I*R3 + I*R4 + I*R1 - V2 - V3 + V1
#Results
print "\n\n Result \n\n"
print "\n (a) unknown currents I1, I2, I3, I4, I5 are ",I1,"A, ", I2,"A, ", I3,"A, ", I4,"A, ", I5,"A respetively\n"
print "\n (b) value of e.m.f. E = ",E," Volts\n"
```

In [2]:

```
from __future__ import division
import math
#initializing the variables:
E1 = 4;# in volts
E2 = 2;# in volts
r1 = 2;# in ohms
r2 = 1;# in ohms
R = 4;# in ohms
#calculation:
#E1 = I1*(r1 + R) + I2*R,
#E2 = I1*R + (R + r2)*I2,
I2 = (E1*R - E2*(r1 + R))/(R**2 - (R+r1)*(R + r2))
I1 = (E1 - I2*R)/(r1 + R)
#Results
print "\n\n Result \n\n"
print "\n currents flowing are, I1 = ",round(I1,3),"A, and I2 = ",round(-1*I2,3),"A, "
print "and current flowing in middle branch is I1 - I2 = ", round(I1 + I2, 3),"A"
```

In [3]:

```
from __future__ import division
import math
#initializing the variables:
E1 = 4;# in volts
E2 = 12;# in volts
R1 = 0.5;# in ohms
R2 = 2;# in ohms
R3 = 5;# in ohms
#calculation:
#E1 + E2 = I1*R1 + I2*R2
#E2 = - I1*R3 + I2*(R2 + R3)
I2 = ((E1 + E2)*R3 + E2*R1)/(R2*R3 + (R2+R3)*R1)
I1 = (E1 + E2 - I2*R2)/R1
#Results
print "\n\n Result \n\n"
print "\n currents flowing are, I1 = ",round(I1,2),"A, and I2 = ",round(I2,2),"A"
print " and in R3 branch is I1 - I2", round(I1 - I2,2)," A"
```

In [4]:

```
from __future__ import division
import math
#initializing the variables:
V = 54;# in volts
I = 8;# in Amps
R1 = 2;# in ohms
R2 = 11;# in ohms
R3 = 14;# in ohms
R4 = 3;# in ohms
R5 = 32;# in ohms
#calculation:
#V = (R1 + R2)*I1 - R2*I2
#0 = (R1 + R3)*I1 - R5*I2 - R3*I
I1 = V*R5/((R1 + R2)*R5 - (R1 + R3)*R2 + R3*I)
I2 = -1*(V - I1*(R2 + R1))/R2
#Results
print "\n\n Result \n\n"
print "\n the current flowing in the 2 ohm resistor = ",round(I1,0),"A,"
print "\n the current flowing in the 14 ohm resistor = ",round(I - I1,0),"A,"
print "\n the current flowing in the 32 ohm resistor = ",round(I2,0),"A,"
print "\n the current flowing in the 11 ohm resistor = ",round(I1 - I2,0),"A,"
print "\n the current flowing in the 3 ohm resistor = ",round(I - I1 + I2,0),"A"
```

In [5]:

```
from __future__ import division
import math
#initializing the variables:
E1 = 4;# in volts
E2 = 2;# in Volts
R1 = 2;# in ohms
R2 = 1;# in ohms
R = 4;# in ohms
#calculation:
I1 = E1/(R1 + (R*R2/(R + R2)))
I2 = (R2/(R + R2))*I1
I3 = (R/(R + R2))*I1
I4 = E2/(R2 + (R*R1/(R + R1)))
I5 = (R1/(R + R1))*I4
I6 = (R/(R + R1))*I4
#Results
print "\n\n Result \n\n"
print "\n Resultant current flowing through source 1 = ",round(I1 - I6,3),"A,"
print "\n Resultant current flowing through source 2 = ",round(I4 - I3,3),"A,"
print "\n Resultant current flowing through resistor R, = ",round(I2 + I5,3),"A,"
```

In [6]:

```
from __future__ import division
import math
#initializing the variables:
E1 = 8;# in volts
E2 = 3;# in Volts
R1 = 3;# in ohms
R2 = 2;# in ohms
R = 18;# in ohms
#calculation:
I1 = E1/(R1 + (R*R2/(R + R2)))
I2 = (R/(R + R2))*I1
I3 = (R2/(R + R2))*I1
I4 = E2/(R2 + (R*R1/(R + R1)))
I5 = (R/(R + R1))*I4
I6 = (R1/(R + R1))*I4
#Results
print "\n\n Result \n\n"
print "\n (a)Resultant current in the 18 ohm resistor= ",round(I3 - I6,3),"A "
print "and P.d. across the 18 ohm resistor",round((I3-I6)*R,3),"V"
print "\n (b)the current in the 8 V battery= ",round(I1 + I5,3),"A"
print "\n (c)current in the 3 V battery = ",round(I2 + I4,3),"A"
```

In [7]:

```
from __future__ import division
import math
#initializing the variables:
V = 10;# in volts
R1 = 2;# in ohms
R2 = 8;# in ohms
R3 = 5;# in ohms
R = 10;# in ohms
#calculation:
I1 = V/(R1 + R2)
E = I1*R2
r = R3 + R1*R2/(R1 + R2)
I = E/(R + r)
#Results
print "\n\n Result \n\n"
print "\n the current flowing in the 10 ohm resistor = ",round(I,3),"A"
```

In [8]:

```
from __future__ import division
import math
#initializing the variables:
V = 12;# in volts
R1 = 1;# in ohms
R2 = 4;# in ohms
R3 = 5;# in ohms
R = 0.8;# in ohms
#calculation:
I1 = V/(R1 + R2 + R3)
E = I1*R2
r = R2*(R1 + R3)/(R1 + R2 + R3)
I = E/(R + r)
#Results
print "\n\n Result \n\n"
print "\n the current flowing in the 0.8 ohm resistor = ",round(I,3),"A"
```

In [9]:

```
from __future__ import division
import math
#initializing the variables:
E1 = 4;# in volts
E2 = 2;# in volts
R1 = 2;# in ohms
R2 = 1;# in ohms
R = 4;# in ohms
#calculation:
I1 = (E1 - E2)/(R1 + R2)
E = E1 - I1*R1
r = R2*R1/(R1 + R2)
I = E/(R + r)
P = R*I**2
#Results
print "\n\n Result \n\n"
print "\n the current flowing in the 4 ohm resistor = ",round(I,3),"A and power dissipated in the 4 ohm resistor = ",round(P,3),"W"
```

In [10]:

```
from __future__ import division
import math
#initializing the variables:
V = 24;# in volts
R = 3;# in ohms
R1 = 20;# in ohms
R2 = 5;# in ohms
R3 = 10;# in ohms
R4 = 5/3;# in ohms
#calculation:
E = R3*V/(R3 + R2)
r = R4 + R3*R2/(R3 + R2)
I = E/(R + r)
#Results
print "\n\n Result \n\n"
print "\n the current flowing in the 3 ohm resistor = ",round(I,0),"A"
```

In [11]:

```
#determine the current in the 32 ohm resistor using Th´evenin’s theorem
from __future__ import division
import math
#initializing the variables:
E = 54;# in volts
R1 = 2;# in ohms
R2 = 14;# in ohms
R3 = 3;# in ohms
R4 = 11;# in ohms
R5 = 32;# in ohms
#calculation:
Vac = R1*E/(R1 + R4)
Vbc = R2*E/(R2 + R3)
V = Vbc - Vac
r = R4*R1/(R1 + R4) + R3*R2/(R3 + R2)
I = V/(R5 + r)
#Results
print "\n\n Result \n\n"
print "\n the current flowing in the 32 ohm resistor = ",round(I,0),"A flowing from A to B"
```

In [12]:

```
from __future__ import division
import math
#initializing the variables:
E = 10;# in volts
R1 = 2;# in ohms
R2 = 8;# in ohms
R3 = 5;# in ohms
R = 10;# in ohms
#calculation:
Isc = E/R1
r = R1*R2/(R1 + R2)
I = r*Isc/(r + R3 + R)
#Results
print "\n\n Result \n\n"
print "\n the current flowing in the 10 ohm resistor = ",round(I,3),"A"
```

In [13]:

```
from __future__ import division
import math
#initializing the variables:
E1 = 4;# in volts
E2 = 2;# in volts
R1 = 2;# in ohms
R2 = 1;# in ohms
R = 4;# in ohms
#calculation:
Isc = E1/R1 + E2/R2
r = R1*R2/(R1 + R2)
I = r*Isc/(r + R)
#Results
print "\n\n Result \n\n"
print "\n the current flowing in the 4 ohm resistor = ",round(I,3),"A"
```

In [14]:

```
from __future__ import division
import math
#initializing the variables:
V = 24;# in volts
R = 3;# in ohms
R1 = 20;# in ohms
R2 = 5;# in ohms
R3 = 10;# in ohms
R4 = 5/3;# in ohms
#calculation:
Isc = V/R2
r = R3*R2/(R3 + R2)
I = r*Isc/(r + R4 + R)
#Results
print "\n\n Result \n\n"
print "\n the current flowing in the 3 ohm resistor = ",round(I,0),"A"
```

In [15]:

```
from __future__ import division
import math
#initializing the variables:
I = 15;# in Amps
R = 2;# in ohms
R1 = 6;# in ohms
R2 = 4;# in ohms
R3 = 8;# in ohms
R4 = 7;# in ohms
#calculation:
Isc = R1*I/(R1 + R2)
r = (R1 + R2)*(R3 + R4)/(R3 + R1 + R4 + R2)
I = r*Isc/(r + R)
#Results
print "\n\n Result \n\n"
print "\n the current flowing in the 2 ohm resistor = ",round(I,2),"A"
```

In [16]:

```
from __future__ import division
import math
#initializing the variables:
V = 10;# in Volts
R = 2;# in ohms
#calculation:
Isc = V/R
#Results
print "\n\n Result \n\n"
print "\n equivalent Norton network contains Current Source of amp = ",round(Isc,0),"A and a resistor of ",R," ohm"
```

In [17]:

```
from __future__ import division
import math
#initializing the variables:
Isc = 4;# in Amps
R = 3;# in ohms
#calculation:
E = Isc*R
#Results
print "\n\n Result \n\n"
print "\n equivalent Thevenin network contains Voltage Source of ",round(E,0),"V and a resistor of ",R," ohm"
```

In [18]:

```
from __future__ import division
import math
#initializing the variables:
E1 = 12;# in Volts
E2 = 24;# in Volts
R1 = 3;# in ohms
R2 = 2;# in ohms
R = 1.8;# in ohms
#calculation:
Isc1 = E1/R1
Isc2 = E2/R2
I1 = Isc1 + Isc2
r = R1*R2/(R1 + R2)
E = I1*r
I = E/(r + R)
#Results
print "\n\n Result \n\n"
print "\n (A)equivalent Norton network contains Current Source of ",round(I1,1),"A and a resistor of ",r," ohm"
print "\n equivalent Thevenin network contains Voltage Source of ",round(E,1),"V and a resistor of ",r," ohm"
print "\n (B)the current flowing in the 1.8 ohm resistor is ",round(I,1),"A"
```

In [19]:

```
from __future__ import division
import math
#initializing the variables:
E1 = 10;# in Volts
E2 = 6;# in Volts
I1 = 0.001;#in Amp
R1 = 2000;# in ohms
R2 = 3000;# in ohms
R3 = 600;# in ohms
R = 200;# in ohms
#calculation:
Isc1 = E1/R1
Isc2 = E2/R2
I2 = Isc1 + Isc2
r1 = R1*R2/(R1 + R2)
E = I2*r1 - I1*R3
r = r1 + R3
I = E/(r + R)
#Results
print "\n\n Result \n\n"
print "\n (A)equivalent Norton network contains Current Source of ",round(I2*1000,0),"mA and a resistor of ",round(r1/1000,1)," Kohm"
print "\n equivalent Thevenin network contains Voltage Source of ",round(E,1),"V and a resistor of ",round(r1/1000,1)," Kohm"
print "\n (B)the current flowing in the 200 ohm resistor is ",round(I*1000,1),"mA"
```

In [1]:

```
from __future__ import division
import math
#from pylab import *
%matplotlib inline
#initializing the variables:
E = 6;# in Volts
R = 2.5;# in ohms
#calculation:
RL = []
P = []
k = []
for h in range(6):
RL.append(h - 0.5)
k = h - 0.5
P.append(k*((E/(R + k))**2))
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.plot(RL,P,'-')
#plot(RL,P,'-')
xlabel('RL(ohm)')
ylabel('Power(W)')
show()
Pmax= R*(E/(2*R))**2
#Results
print "\n\n Result \n\n"
print "\n A graph of RL against P is shown in Figure"
print " The maximum value of power is", Pmax,"W which occurs when RL =",R,"ohm"
```

In [21]:

```
from __future__ import division
import math
from pylab import *
#initializing the variables:
E = 30;# in Volts
R = 1.5;# in ohms
#calculation:
RL = R
I = E/(R + RL)
P = I**2*RL
#Results
print "\n\n Result \n\n"
print " The maximum value of power is", P,"W which occurs when RL =",RL,"ohm"
```

In [22]:

```
from __future__ import division
import math
from pylab import *
#initializing the variables:
V = 15;# in Volts
R1 = 3;# in ohms
R2 = 12;# in ohms
#calculation:
E = (R2/(R2+ R1))*V
r = R1*R2/(R1 + R2)
RL = r
I = E/(r + RL)
P = I**2*RL
#Results
print "\n\n Result \n\n"
print " The maximum value of power is", P,"W which occurs when Total Load RL =",RL,"ohm"
```