In [1]:

```
#Variable declaration
E = 24.; # E.m.f of battery,V
R1 = 330; # Resistance, ohms
R2 = 1500; # Resistance, ohms
R3 = 470; # Resistance, ohms
#Calculations
# As resistances R1, R2 & R3 are joined end-to-end hence, they are in series & in series connection, circuit resistance is the sum of individual resistances present in the circuit
R = R1 + R2 + R3; # Resistance of circuit, ohms
I = E/R; # Circuit current, A
# As the resistances are in series so same current flows through each resistor & potential drop across each resistor is equal to the product of circuit current & its respective resistance( from Ohm's law, V = I*R )
V1 = I*R1; # Potential difference developed across resistance R1, V
V2 = I*R2; # Potential difference developed across resistance R2, V
V3 = I*R3; # Potential difference developed across resistance R3, V
P = E*I; # Electric power dissipated by the complete circuit, W
# Results
print "The circuit resistance = %4d ohms or %3.1f kilo-ohms"%(R, R*1e-03);
print "The circuit current = %5.2f milli-ampere"%(I/1e-03);
print "The potential drop across resisatnce R1 = %4.2f volts\nThe potential drop across resistance R2 = %5.2f volts\nThe potential drop across resistance R3 = %4.2f volts"%(V1, V2, V3);
print "The power dissipated by the complete circuit = %4.2f watt or %3d milli-watt"%(P,P/1e-03)
```

In [16]:

```
import math
#Variable declaration
E = 12.; # E.m.f of battery, V
R_BC = 16.; # Resistance across branch BC, ohms
P_BC = 4; # Electric power dissipated by resistance R_BC, W
#Calculations
# using relation P = I^2/R, solving for I
I = math.sqrt( P_BC/R_BC); # Electric current,A
R = E/I; # Total circuit resistance, ohms
R_AB = R - R_BC; # Resistance across branch AB, ohms
# Result
print "The circuit current = %3.1f A\nThe value of other resistor = %1d ohms"%(I, R_AB)
```

In [3]:

```
#Variable declaration
E = 24.; # E.m.f of battery, V
R_1 = 330.; # Resistance, ohms
R_2 = 1500.; #Resistance, ohms
R_3 = 470.; #Resistance, ohms
#Calculations
# Since one end of each resistor is connected to positive terminal of battery and the other end to the negative terminal, therefore, the resistors are in parallel & in parallel connection the equivalent resistance of the circuit is equal to the reciprocal of the sum of conductances of individual resistances present in the circuit i.e 1/R = 1/R_1 + 1/R_2 + 1/R_3, solving for R
R = (R_1*R_2*R_3)/( R_1*R_2 + R_2*R_3 + R_3*R_1); # Equivalent resisance of circuit, ohms
# Since the resistances are in parallel so potetial difference across each resistor is same & in our case is equal to e.m.f of battery & from Ohm's law, V = I*R, solving for I
I_1 = E/R_1; # Current through resistor R_1, A
I_2 = E/R_2; # Current through resistor R_2, A
I_3 = E/R_3; # Current through resistance R_3, A
# Current drawn from battery is equal to the sum of branch currents
I = I_1 + I_2 + I_3; # Current drawn from battery, A
# Results
print "The total resistance of the circuit = %6.2f ohms"%(R);
print "The branch current I1 = %5.2f mA\nThe branch current I2 = %2d mA\nThe branch current I3 = %5.2f mA"%(I_1/1e-03, I_2/1e-03, I_3/1e-03);
print "The current drawn from the battery = %5.1f mA"%(I/1e-03)
```

In [4]:

```
#Variable declaration
E = 12; # E.m.f of battery, V
R1 = 6; # Resistance, ohms
R2 = 3; # Resistance, ohms
#Calculations
# Since the two resistances are in parallel, therefore effective resistance of the circuit is equal to the reciprocal
#of the sum of conductances ( 1/Ressistance) of individual resistances present in the circuit i.e 1/R = 1/R1 + 1/R2,
#simplifying for R
R = ( R1*R2)/(R1 + R2); # Effective resistance of the circuit, ohms
# Fron Ohm's law, V = I*R, solving for I
I = E/R; # Circuit current, A
I1 = E/R1; # Current through resistance R1, A
I2 = E/R2; # Current thrugh resistance R2, A
# Results
print "Effective resistance of the circuit = %1d ohms"%R
print "The current drawn from the battery = %1d A"%I
print "The current through resistor R1 = %1d A"%I1
print "The current through R2 resistor = %1d A"%I2
```

In [5]:

```
#Variable declaration
R1 = 10.; # Resistance, ohm
R2 = 20.; # Resistance, ohm
R3 = 30.; # Resistance, ohm
#Calculations
# Part (a)
# Since in series combination, the equivalent resistance of the circuit is the sum of the individual resistances
#present in the circuit i.e R = R1 + R2 + R3
R_s = R1 + R2 + R3; # Equivalent series resistance of the circuit, ohms
# Part (b)
# Since in parallel combination, the equivalent resistance of the circuit is the reciprocal of the sum of the
#conductances of the individual resistances present in the circuit i.e 1/R = 1/R1 + 1/R2 + 1/R3, solving for R;
R_p = ( R1*R2*R3 )/( R1*R2 + R2*R3 + R3*R1 ); # Equivalent parallel resistance of the circuit, ohms
# Results
print "Equivalent series resistance of the circuit = %2d ohm"%R_s
print "Equivalent parallel resistance of the circuit = %4.2f ohm"%R_p
```

In [6]:

```
#Variable declaration
E = 64.; # E.m.f of battery, V
R1 = 6.; # Resistance, ohm
R2 = 4.; # Resistance, ohm
#Calculations
# Part (a)
# Since R1 & R2 are parallel to one another hence, their equivalent resistance is equal to the sum of reciprocal of
#their individual resistances
R_BC = ( R1*R2)/( R1 + R2 ); # Equivalent resistance across branch BC, ohm
R_AB = 5.6; # Resistance across branch AB, ohm
# Since R_AB & R_BC are in series, therefore, their equivalent resistance is equal to the sum of their individual
#resistances
R_AC = R_AB + R_BC; # Total circuit resistance, ohm
# From Ohm's law, V = I*R, solving for I
I = E/R_AC; # Total circuit current, A
# Part (b)
V_BC = I*R_BC; # Potential difference across branch BC, V
I1 = V_BC/R1; # Electric current through resistor R1, A
# Part (c)
# Since P = I^2*R
P_AB = I**2*R_AB; # Power dissipated by 5.6 ohm resistance, W
# Results
print "The current drawn from the supply = %1d A "%I;
print "The current through %1d ohm resistor = %3.1f A"%(R1, I1);
print "The power dissipated by %3.1f ohm resistor = %5.1f W"%(R_AB, P_AB);
```

In [7]:

```
#Variable declaration
E = 18.; # E.m.f of battery, V
R1 = 4.; # Resistance, ohm
R2 = 6.; # Resistance, ohm
R3 = 5.; # Resistance, ohm
R4 = 3.; # Resistance, ohm
R5 = 6.; # Resistance, ohm
R6 = 8.; # Resistance, ohm
#Calculations
# Part (a)
# Since resistance R1 & R2 are in parallel, therefore, equivalent resistance across branch AB will be equal to the
#reciprocal of the sum of conductances ( 1/Ressistance) of individual resistances present in the circuit
#i.e 1/R_AB = 1/R1 + 1/R2, simplifying for R_AB
R_AB = ( R1*R2 )/( R1 + R2); # Resistance, ohm
R_BC = R3; # Resistance across branch BC, ohm
# Since resistance R4, R5 & R6 are in parallel, therefore, equivalent resistance across branch CD will be equal to
#the reciprocal of the sum of conductances ( 1/Ressistance) of individual resistances present in the circuit
#i.e 1/R_CD = 1/R4 + 1/R5 + 1/R6, simplifying for R _CD
R_CD = ( R4*R5*R6 )/( R4*R5 + R5*R6 + R6*R4 ); # Resistance, ohm
# Since R_AB, R_BC & R_CD forms series combination, therefore circuit resistance will be their series sum
R = R_AB + R_BC + R_CD; # Circuit resistance, ohm
I = E/R; # Supply current, A
# Part (b)
# AS resistances R1 & R2 are parallel, therefore tere will be same potential difference across them, denoted by V_AB
V_AB = I*R_AB; # Potential difference, V
# AS resistances R4, R5 & R6 are parallel, therefore tere will be same potential difference across them, denoted by V_CD
V_CD = I*R_CD; # Potential difference, V
V_BC = I*R_BC; # Potential difference, V
# Part (c)
I1 = V_AB/R1; # Current through R1 resistor, A
I2 = V_AB/R2; # Current through R2 resistor, A
I4 = V_CD/R4; # Current through R4 resistor, A
I5 = V_CD/R5; # Current through R5 resistor, A
I6 = V_CD/R6; # Current through R6 resistor, A
# Part (d)
P3= I**2*R3; # Power dissipated, W
# Results
print "The current drawn from the source = %1d A"%I
print "The p.d. across resistor %1d ohm & %1d ohm = %3.1f V"%(R1, R2, V_AB);
print "The p.d. across resistor %1d ohm, %1d ohm & %1d ohm = %3.1f V"%(R4, R5, R6, V_CD);
print "The p.d. across resistor %1d ohm = %2d V"%(R3, V_BC);
print "The current through resistor %1d ohm = %3.1f A"%(R1, I1);
print "The current through resistor %1d ohm = %3.1f A"%(R2, I2);
print "The current through resistor %1d ohm = %1d A"%(R3, I);
print "The current through resistor %1d ohm = %5.3f A"%(R4, I4);
print "The current through resistor %1d ohm = %5.3f A"%(R5,I5);
print "The current through resistor %1d ohm = %3.1f A"%(R6, I6);
print "The power dissipated by the %1d ohm resistor = %2d W"%(R3, P3);
```

In [8]:

```
#Variable declaration&Calculations
# Applying Kirchhoff's current law (the sum of the currents arriving at a junction is equal to the sum of the
#currents leaving that junction) at junction A
I2 = 40 + 10; # Electric current, A
# Applying Kirchhoff's current law at junction C
I1 = 80 - I2; # Electric current, A
# Applying Kirchhoff's current law at junction D
I3 = 80 + 30; # Electric current, A
# Applying Kirchhoff's current law at junction E
I4 = I3 - 25; # Electric current, A
# Applying Kirchhoff's current law at junction F
I5 = 30 - 85; # Electric current, A
# Result
print "Current I1 = %2d A\nCurrent I2 = %2d A\nCurrent I3 = %3d A\nCurrent I4 = %2d A\nCurrent I5 = %2d A,"%(I1, I2, I3, I4, I5);
```

In [9]:

```
import numpy as np
from numpy import linalg
from numpy.linalg import inv
#Variable declaration
R1 = 3; # Resistance, ohms
R2 = 2; # Resistance, ohms
R3 = 10; # Resistance, ohms
E1 = 10; # E.m.f, V
E2 = 4; # E.m.f, V
#Calculations
# Applying Kirchhoff's Current Law(the sum of the currents arriving at a junction is equal to the sum of the
#currents leaving that junction)
A = np.array([[3.,-2.],[13.,10.]])
B = np.array([6.,10.])
I1,I2 = np.linalg.solve(A,B)
I3 = ( I1 + I2 ); # Electric current through branch CD, A
V_CD = R3*I3; # P.d.across R3 resistor, V
# Results
print "The current through branch FA = %6.3f A"%I1
print "The current through branch EB = %5.3f A"%I2
print "The current through branch CD = %5.3f A"%I3
print "p.d.across %2d resistor = %4.2f V"%(R3,V_CD)
```

In [10]:

```
import numpy as np
from numpy import linalg
#Variable declaration
E1 = 6; # E.m.f of battery, V
E2 = 4.5; # E.m.f of battery, V
R1 = 1.5; # Resistance, ohm
R2 = 2; # Resistance, ohm
R3 = 5; # Resistance, ohm
#Calculations
# Part (a)
# Using matrix method for solving set of equations
A = np.array([[6.5, 5], [5, 7]])
B = np.array([6, 4.5]);
#X = inv(A)*B;
I1,I2 = np.linalg.solve(A,B) # Electric current through branch FA & DC, A
I3 = ( I1 + I2); # Electric current through branch BE, A
# Part (b)
V_BE = I3*R3; # P.d across resistor R3, V
# Results
print "Electric current through branch FA = %5.3f A"%I1
print "Electric current through branch DC = %6.4f A"%I2
print "Electric current through branch BE = %5.3f A"%I3
print "p.d across resistor %1d ohms = %5.3f V"%(R3, V_BE);
```

In [11]:

```
import numpy as np
from numpy import linalg
#Variable declaration
R_AB = 6; # Resistance, ohm
R_BC = 4; # Resistance, ohm
R_DC = 1; # Resistance, ohm
R_AD = 3; # Resistance, ohm
R_BD = 5; # Resistance, ohm
#Calculations
# Using matrix method for solving the set of equations
A = np.array([[6, -3, 5], [-4, 1, 10], [0, 4, 1]]);
B = ([0, 0, 10]);
#X = inv(A)*B;
I1,I2,I3 = np.linalg.solve(A,B); # Electric current, A
I_BC = I1 - I3; # Electric current, A
I_DC = I2 + I3; # Electric current, A
I = I1 + I2; # Supply current, A
# Results
print "The current through %1d ohm resistor = %5.3f A"%(R_AB, I1)
print "The current through %1d ohm resistor = %4.2f A"%(R_BC, I_BC);
print "The current through %1d ohm resistor = %5.3f A"%(R_DC, I_DC);
print "The current through %1d ohm resistor = %5.3f A"%(R_AD, I2);
print "The current through %1d ohm resistor = %5.3f A"%(R_BD, I3);
print "The supply current = %5.3f A"%I
```

In [12]:

```
#Variable declaration
R_AB = 6; # Resistance across branch AB, ohm
R_AD = 3; # Resistance across branch AD, ohm
R_BC = 4; # Resistance across branch BC, ohm
R_DC = 2; # Resistance across branch DC, ohm
#Calculations
# Since R_AB/R_AD = R_BC/R_DC, so the wheatstone bridge is balanced hence no current flows through branch BD
I3 = 0;
# Result
print "The current through branch BD i.e I3 = %1d A"%I3
```

In [13]:

```
import numpy as np
from numpy import linalg
#Variable declaration
R1 = 20; # Resistance, ohm
R2 = 10; # Resistance, ohm
R3 = 8; # Resistance, ohm
R4 = 5; # Resistance, ohm
R5 = 2; # Resistance, ohm
#Calculations
A = np.array([[20, -10, 8], [-5, 2, 15], [0, 12, 2]]);
B = np.array([0, 0, 10]);
I1,I2,I3 = np.linalg.solve(A,B) # Electric current through BD, A
V_BD = I3*R3; # P.d across branch BD, V
# For balance conditions i.e I3 = 0, R1/R2 = R4/R5, solving for R4
R_4 = ( R1*R5 )/R2; # Resistance, ohm
# Results
print "The p.d between terminals B and D = %5.3f V"%V_BD
print "The value to which %1d ohm resistor must be adjusted in order to reduce the current through %1d ohm resistor to zero = %1d ohm"%(R4, R3, R_4);
```

In [14]:

```
#Variable declaration
# For part (a)
Rm = 1000.; # Resistance, ohm
Rd = 1; # Resistance, ohm
Rv = 3502.; # Resistance, ohm
# Using Wheatstone bridge balanced condition i.e Rx/Rv = Rm/Rd , solving for Rx
Rx = ( Rm/Rd) * Rv; # Resistance,ohm
print "The value of the resistance being measured = %5.3f mega-ohm"%(Rx*1e-06);
# Part (b)
Rm = 1.; # Resistance, ohm
Rd = 1000; # Resistance, ohm
Rv = 296; # Resistance, ohm
# Using Wheatstone bridge balanced condition i.e Rx/Rv = Rm/Rd , solving for Rx
Rx = ( Rm/Rd )*Rv; # Resistance,ohm
print "The value of the resistance being measured = %5.3f ohm"%Rx
```

In [15]:

```
#Variable declaration
l1 = 600e-03; # Scale reading, metre
l2 = 745e-03; # Scale reading, metre
l_s = 509.3e-03; # Total scale length, metre
E_s = 1.0186; # Source voltage, V
#Calculations
E1 = ( l1/l_s )*E_s; # Voltage drop across length l1, V
E2 = ( l2/l_s)*E_s; # Voltage drop across length l2, V
# Results
print "The emf of the first cell = %3.1f V "%E1
print "The emf of the second cell = %3.2f V "%E2
```