In [1]:

```
from __future__ import division
import math
#given data :
n=20;# dry cells of emf
E=1.5;# emf in volts
R=5; # external resistance in ohm
r=0.5;# internal resistance in ohm
#calculations:
I=(n*E)/(R+(n*r));
#Results
print "current flowing,I(A) = ",I
```

In [2]:

```
from __future__ import division
import math
#given data :
n=10;# dry cells of emf
E=1.5;# emf in volts
R=4.9;# resistance in ohm
r=1; # internal resistance in ohm
#calculations:
I=(n*E)/((n*R)+(r));
#Results
print "current flowing,I(A) = ",I
```

In [3]:

```
from __future__ import division
import math
#given data :
m=3;
n=10;# dry cells of emf
E=1.5;# emf in volts
R=2.5;# resistance in ohm
r=0.5;# internal resistance in ohm
#colculations:
I=(m*n*E)/((m*R)+(n*r));
#Results
print "current flowing,I(A) = ",I
```

In [4]:

```
from __future__ import division
import math
#given data:
n=10 # no. of cells
Rl=4 # LOAD RESISTANCE
V=12 # in volts
Va=18# IN VOLTS
#calculations:
r=((Va-V)*Rl)/(n*V)# internal resistance in ohms
Il=V/Rl# IN AMPERES
#Results
print "(a)internal resistance in ohms is",r
print "(b)load current in amperes is", Il
```

In [11]:

```
from __future__ import division
import math
#given data:
n=6 # no. of cells
Rl=3 # LOAD RESISTANCE
I=2.5# IN AMPERES
r1=9 # in ohms
I2=1.25# om amperes
#calculations:
r=((r1*I2)-(Rl*I))/(n*(I-I2))# internal resistance in ohms
E=((I*(Rl+n*r))/n)# emf of each cell in volts
#Results
print "emf of each cell in volts is", E
print "internal resistance of each cell in ohms is",r
```

In [6]:

```
from __future__ import division
import math
#given data:
I=20 # in amperes
t=15 # in hours
#calculations
Ah=I*t# ampere hour capacity of the battery
#Results
print "ampere hour capacity of the battery in A-h is",Ah
```

In [7]:

```
from __future__ import division
import math
#given data:
I=30 # in amperes
t=6 # in hours
Vt=2 # terminal voltage
Ic=40# in amperes
tc=5 # in hours
Vc=2.5# in volts
#calculations:
Aho=I*t# ampere hour output of the battery
Ahi=Ic*tc# ampere hour input of the battery
nAh=(Aho/Ahi)*100# ampere hour efficiency
Who=I*t*Vt# watt hour output of the battery
Whi=Ic*tc*Vc# watt hour input of the battery
nWh=(Who/Whi)*100# ampere hour efficiency
#Results
print "(a)ampere hour efficiency of the battery in percentage is",nAh
print "(b)watt hour efficiency of the battery in percentage is",nWh
```

In [8]:

```
from __future__ import division
import math
#given data:
n=50 # no. of cells
Vc=250# in volts
Vd=1.8#in volts
Vcs=2.2#in volts
r=0.01#internal resistance of each cell in ohms
rl=0.1#lead resistance in ohms
Re=19.4#external resitance in ohms
#calculations:
Ib=n*r# internal resistnce of battery
Tb=rl+Ib#total resistance of battery
Eb=Vd*n#total rmf of battery
I=(Vc-Eb)/(Re+Tb)# initial charging current in amperes
Ebf=Vcs*n#emf of the battery at the end of charging
If=(Vc-Ebf)/(Re+Tb)# initial charging current in amperes
#Results
print "(a)initial charging current in amperes is",I
print "(b)final charging current in amperes is",If
```

In [9]:

```
from __future__ import division
import math
import numpy as np
#given data:
V=230# in volts
emf1=122#in volts
r=0.4#internal resistance in ohms
emf2=130#in volts
r1=0.5#in ohms
R = 5; #in ohm
# calculations:
#apllying kirchoff's low
# x ampere is the total current taken by battery
# x1 ampere is the total current taken by battery A
# x-x1 ampere is the total current taken by battery B
# 5*x+0.4*y=180 is the equation in mesh ABEF
# 5.5*x+0.5*y=100 equation in the mesh CDEF
# equation 1 is 25*x+2*y=540 and equation 2 is 22*x-2*y=400
A=np.array([[25, 2],[22,-2]])# EQUATIONS
B=np.array([540,400])# VALUES
X=np.linalg.solve(A, B)# UNKNOW VALUES
I=X[0]#TOTAL CURRENT IN AMPERES
x1=X[1]#current taken by battery A
x2=I-x1#
p=(I**2)*R# in watt
#Results
print "(a1)current in battery A in amperes (discharging) is",x1
print "(a2)current in bettery B in amperes is",round(x2,1)
print "(b)total current in battery A and B in amperes (charging)",I
print "(c)power dissipated in watts is",p
```

In [10]:

```
from __future__ import division
import math
import numpy as np
#given data:
V=34 # in volts
emf1=2#in volts
r1=6 #in ohms
r2=1 #in ohms
r3=2 #in ohms
r4=4 # in ohms
# calculations:
#apllying kirchoff's low
# x ampere is the current in branch AB
# x1 ampere is the current in branch AC
#x2 ampere is the current in the Branch BD
# x-x2 ampere is the current in the branch BC
# x1+x2 ampere is the current in the branch DC
# x-6*x1+8*x2=2 in mesh ABD
# 2*x-4*x1-14*x2=-2 in mesh BCD
# 10*x1+4*x2=34;//in mesh ADCEF
A=np.array([[1,-6,8],[2,-4,-14],[0,10,4]])# EQUATIONS
B=np.array([2,-2,34])# VALUES
X=np.linalg.solve(A, B)# UNKNOW VALUES
x=X[0]#TOTAL CURRENT IN AMPERES
x1=X[1]#current taken by battery A
x2=X[2]#
b1=x-x2# in amperes
b2=x1+x2#in amperes
R=((r1*x1+r4*(x2+x1))/(x+x1))#total resistance in ohms
#Results
print "current in 1 ohms resistance from A to B in amperes is",x
print "current in 6 ohms resistance from A to D in amperes is",x1
print "current in 8 ohms resistance from B to D in amperes is",x2
print "current in 2 ohm resistance from B to C in amperes is",b1
print "current in 4 ohm resistance from D to C in amperes is",b2
print "total reistance in ohms is",round(R,2)
```