In [1]:

```
#Variable declaration
MgSO4=60.0 #[mg]
M_MgSO4=64.0 #Molecular weight of MgSO4
M_CaCO3=48.0 #Molecular wt of CaCO3
m_mgso4=120.0 #Weight of MgSO4 eq to CaCO3
m_caco3=100.0 #Weight of CaCO3 eq to MgSO4
#Calculation
hard=(m_caco3/m_mgso4)*MgSO4 #Hardness of water in mg
#Result
print"Hardness of water is ",hard,"ppm"
```

In [2]:

```
#Variable declaration
W1=16.2 #Ca(HCO3)2 in water in mg/lit#
W2=7.3 #MgHCO3 in water in mg/lit#
W3=13.6 #CaSO4 in water in mg/lit#
W4=9.5 #MgCl2 in water in mg/lit#
M1=100/162.0 #multiplication factor of Ca(HCO3)2#
M2=100/146.0 #multiplication factor of MgHCO3#
M3=100/136.0 #multiplication factor of CaSO4#
M4=100/95.0 #multiplication factor of MgCl2#
#Calculation
P1=W1*M1 #Ca(HCO3)2 in terms of CaCO3 or #
P2=W2*M2 #MgHCO3 in terms of CaCO3 or #
P3=W3*M3 #CaSO4 in terms of CaCO3 or #
P4=W4*M4 #MgCl2 in terms of CaCO3 or #
T=P1+P2 #Temporary hardness
P=P3+P4 #Permanent hardness
To=T+P #Total hardness
#Result
print"Temporary hardness is",T,"mg/l or ppm"
print"\nPermanant hardness is ",P,"mg/l or ppm"
print"\nTotal hardness is ",To,"mg/l or ppm"
```

In [3]:

```
#Variable declaration
F=56.0 #atomic weight of ferrus#
S=32.0 #atomic weight of sulphur#
O=16.0 #atomic weight of oxygen#
Ca=40.0 #atomic weight of calsium#
C=12.0 #atomic weight of carbon#
#Calculation
W1=136
P=210.5 #required ppm of hardness#
B=(W1/100.0)*P
#Result
print"Required FeSO4 for 100ppm of hardness is",W1,"ppm pf FeSO4"
print"\nRequired FeSO4 for 210.5ppm of hardness is ",round(B,1),"ppm of FeSO4"
```

In [4]:

```
#Variable declaration
W1=162.0 #Ca(HCO3)2 in water in mg/lit#
W2=73.0 #MgHCO3 in water in mg/lit#
W3=136.0 #CaSO4 in water in mg/lit#
W4=95.0 #MgCl2 in water in mg/lit#
W5=111.0 #CaCl2 in water in mg/lit#
W6=100.0 #NaCl in water in mg/lit#
M1=100/162.0 #multiplication factor of Ca(HCO3)2#
M2=100/146.0 #multiplication factor of MgHCO3#
M3=100/136.0 #multiplication factor of CaSO4#
M4=100/95.0 #multiplication factor of MgCl2#
M5=100/111.0 #multiplication factor of CaCl2#
M6=100/100.0 #multiplication factor of NaCl#
#Calculation
P1=W1*M1 #Ca(HCO3)2 in terms of CaCO3 or #
P2=W2*M2 #MgHCO3 in terms of CaCO3 or #
P3=W3*M3 #CaSO4 in terms of CaCO3 or #
P4=W4*M4 #MgCl2 in terms of CaCO3 or #
P5=W5*M5 #CaCl2 in terms of CaCO3 or #
T=P1+P2
P=P3+P4+P5
#Result
print"\nTemporary hardness is",T,"mg/l or ppm"
print"\nPermanant hardness is",P,"mg/l or ppm"
```

In [5]:

```
#Variable declaration
N=0.08 #normality of MgSO4#
V1=12.5 #volume of MgSO4 in ml#
V2=100 #volume of water sample#
#Calculation
M=N/2 #molarity of MgSO4#
N1=(M*12.5)/1000 #no of moles of MgSO4 in 100 ml water#
N2=(N1*1000)/100 #no of moles of MgSO4 in one litre water#
W=100 #molecular weight of CaCO3
W1=N2*W*1000 #MgSO4 in terms of CaCO3 in mg/lit#
#Result
print"\nThe hardness due to MgSO4 is ",W1,"mg/l CaCO3 or ppm of CaCO3"
```

In [6]:

```
#Variable declaration
W1=144.0 #MgCO3 in water in mg/lit#
W2=25.0 #CaCO3 in water in mg/lit#
W3=111.0 #CaCl2 in water in mg/lit#
W4=95.0 #MgCl2 in water in mg/lit#
M1=100/84.0 #multiplication factor of MgCO3#
M2=100/100.0 #multiplication factor of CaCO3#
M3=100/111.0 #multiplication factor of CaCl2#
M4=100/95.0 #multiplication factor of MgCl2#
#Calculation
P1=W1*M1 #MgCO3 in terms of CaCO3 or ppm#
P2=W2*M2 #CaCO3 in terms of CaCO3 or ppm#
P3=W3*M3 #CaCl2 in terms of CaCO3 or ppm#
P4=W4*M4 #MgCl2 in terms of CaCO3 or ppm#
V=50000 #volume of water in lit#
L=0.74*(2*P1+P2+P4)*V
S=1.06*(P1+P3+P4)*V
#Result
print"Requirement of lime is ",L,"mg=",round(L/1000000,1),"kg"
print"\nRequirement of soda is ",S,"mg=",round(S/1000000,1),"kg"
```

In [7]:

```
#Variable declaration
W1=12.0 #Mg2+ in water in ppm or mg/l#
W2=40.0 #Ca2+ in water in ppm or mg/l#
W3=164.7 #HCO3- in water in ppm or mg/l#
W4=30.8 #CO2 in water in ppm or mg/l#
M1=100.0/24.0 #multiplication factor of Mg2+#
M2=100.0/40.0 #multiplication factor of Mg2+#
M3=100.0/61.0 #multiplication factor of Mg2+#
M4=100.0/44.0 #multiplication factor of Mg2+#
#Calculation
P1=W1*M1 # in terms of CaCO3#
P2=W2*M2 # in terms of CaCO3#
P3=W3*M3/2 # in terms of CaCO3#
P4=W4*M4 # in terms of CaCO3#
V=50000.0#volume of water in lit#
L=0.74*(P1+P3+P4)*V
#Result
print"Lime required is %fmg",round(L/10**6,1),"kg"
```

In [8]:

```
#Variable declaration
W1=160.0 #Ca2+ in water in mg/l or ppm#
W2=72.0 #Mg2+ in water in mg/l or ppm#
W3=732.0 #HCO3- in water in mg/l or ppm#
W4=44.0 #CO2 in water in mg/l or ppm#
W5=16.4 #NaAlO2 in water in mg/l or ppm#
W6=30.0 #(CO3)2- in water in mg/l or ppm#
W7=17.0 #OH- in water in mg/l or ppm#
#Calculation
M1=100/40.0 #multiplication factor of Ca2+#
M2=100/24.0 #multiplication factor of Ca2+#
M3=100/(61.0*2.0) #multiplication factor of Ca2+#
M4=100/44.0 #multiplication factor of Ca2+#
M5=100/(82.0*2.0) #multiplication factor of Ca2+#
M6=100/60.0 #multiplication factor of Ca2+#
M7=100/(17.0*2.0) #multiplication factor of Ca2+#
P1=W1*M1 #in terms of CaCO3#
P2=W2*M2 #in terms of CaCO3#
P3=W3*M3 #in terms of CaCO3#
P4=W4*M4 #in terms of CaCO3#
P5=W5*M5 #in terms of CaCO3#
P6=W6*M6 #in terms of CaCO3#
P7=W7*M7 #in terms of CaCO3#
V=200000.0 #volume of water in lit#
L=0.74*(P2+P3+P4-P5+P7)*V
L=L/10.0**6.0 #in kgs#
S=1.06*(P1+P2-P3-P5-P6+P7)*V
S=S/10.0**6 #in kgs#
#Result
print"Lime required is ",L,"kg"
print"\nSoda required is ",S,"kg"
```

In [9]:

```
#Variable declaration
N=150.0 #amount of NaCl in solution in g/l#
V=8.0 #volume of NaCl solution#
#Calculation
M=N*V
V=10000.0 #volume of hard water#
W=58.5 #molecular weight of NaCl#
K=(M*100.0/(W*2))/V
J=K*1000.0
#Result
print"\nHardness of water is ",round(J,1),"mg/l or ppm"
```

In [10]:

```
#Variable declaration
W1=219.0 #amount of Mg(HCO3)2 in water in ppm#
W2=36.0 #amount of Mg2+ in water in ppm#
W3=18.3 #amount of (HCO3)- in water in ppm#
W4=1.5 #amount of H+_in water in ppm#
M1=100/146.0 #multiplication factor of Mg(HCO3)2#
M2=100/24.0 #multiplication factor of Mg(HCO3)2#
M3=100/122.0 #multiplication factor of Mg(HCO3)2#
M4=100/2.0 #multiplication factor of Mg(HCO3)2#
#Calculation
P1=W1*M1 #in terms of CaCO3#
P2=W2*M2 #in terms of CaCO3#
P3=W3*M3 #in terms of CaCO3#
P4=W4*M4 #in terms of CaCO3#
L=0.74*((2*P1)+P2+P3+P4)
R=1.0 #water supply rate in m**3/s#
D=R*60.0*60.0*24.0*L
K=D*1000.0 #in lit/day#
T=K/10.0**9 #in tonnes#
S=1.06*(P2+P4-P3)
D2=R*60*60*24*S
A=D2*1000 #in lit/day#
B=A/10.0**9 #in tonnes#
J1=90/100.0 #purity of lime#
J2=95/100.0 #purity of soda#
C1=500.0 #cost of one tonne lime#
C2=7000.0 #cost of one tonne soda#
CL=round(T,1)*C1/J1
print"\ncost of lime is",CL,"Rs"
CS=round(B,1)*C2/J2
print"\ncost of soda is ",CS,"Rs"
C=CL+CS
#Result
print"\ntotal cost is ",round(C) ,"Rs"
```

In [11]:

```
#Variable declaration
W1=40.0 #amount of Ca2+ in water in mg/l#
W2=24.0 #amount of Mg2+ in water in mg/l#
W3=8.05 #amount of Na+ in water in mg/l#
W4=183.0 #amount of (HCO3)- in water in mg/l#
W5=55.68 #amount of (SO4)2- in water in mg/l#
W6=6.74 #amount of Cl- in water in mg/l#
M1=100/40.0 #multiplication factor of Ca2+#
M2=100/24.0 #multiplication factor of Mg2+#
M3=100/(23.0*2) #multiplication factor of Na+#
M4=100/(61.0*2) #multiplication factor of (HCO3)-#
M5=100/96.0 #multiplication factor of (SO4)2-#
M6=100/(35.5*2) #multiplication factor of Cl-#
#Calculation
P1=W1*M1 #in terms of CaCO3#
P2=W2*M2 #in terms of CaCO3#
P3=W3*M3 #in terms of CaCO3#
P4=W4*M4 #in terms of CaCO3#
P5=W5*M5 #in terms of CaCO3#
P6=W6*M6 #in terms of CaCO3#
#Result
print"\nCalcium alkalinity =",P1,"ppm"
print"\nMagnesium alkalinity =",P4-P1,"ppm"
print"\n total alkalinity = ",P1+P4-P1,"ppm"
print"\n total hardness = ",P1+P2,"ppm"
print"\nCa temporary hardness = ",P1,"ppm"
print"\nMg temporary hardness = ",P4-P1,"ppm"
print"\nMg permanant hardness = ",P2-(P4-P1),"ppm"
print"\nSalts are:"
print"\nCa(HCO3)2 salt = ",P1,"ppm"
print"\nMg(HCO3)2 salt = ",P4-P1,"ppm"
print"\nMgSO4 salt = ",P2-(P4-P1),"ppm"
print"\nNaCl salt = ",P6,"ppm"
```

In [12]:

```
#Variable declaration
P=0.0 #phenolplthalein alkalinity in water sample#
V=16.9 #required HCl in ml for 100 ml water sample#
N=0.02 #normality of HCl#
print"Since P=0 the alkalinity is due to HCO3- ions"
C=50.0 #equivalent of CaCO3 in mg for 1 ml 1N of HCl#
#Calculation
A=C*V*N
print"\nIn 100ml water sample the alkalinity is",A,"mg/s"
B=A*1000.0/100.0
#Result
print"\nFor 1 litre of water the alkalinity is ",B,"mg/l"
```

In [13]:

```
#Variable declaration
P=4.7 #required HCl in ml using HpH indicator #
H=10.5 #required HCl im ml using MeOH indicator#
M=P+H
N=0.02 #normality of HCl#
print"\nSince P<0.5*M sample contain (CO3)2- and (HCO3)- alkalinity"
C=50 #equivalent of CaCO3 in mg for 1ml 1N HCl#
#Calculation
A=C*(2*P)*N #amount of (CO3)2- alkalinity in mg in 100 ml of water#
B=A*1000/100
D=C*(M-2*P)*N #the amount of (HCO3)- alkalinity in mg in 100 ml of water#
E=D*1000/100
T=B+E
#Result
print"\nTotal alkalinity is ",T,"mg/l or ppm"
```

In [14]:

```
#Variable declaration
W1=160.0 #amount of Ca2+ in ppm#
W2=88.0 #amount of Mg2+ in ppm#
W3=72.0 #amount of CO2 in ppm#
W4=488.0 #amount of (HCO3)- in ppm#
W5=139.0 #amount of (FeSO4).7H2O in ppm#
M1=100/40.0 #multiplication factor of Ca2+#
M2=100/24.0 #multiplication factor of Mg2+#
M3=100/44.0 #multiplication factor of CO2#
M4=100/(61.0*2.0) #multiplication factor of (HCO3)-#
M5=100/278.0 #multiplication factor of (FeSO4).7H2O#
P1=400 #in terms of CaCO3#
P2=300 #in terms of CaCO3#
P3=200 #in terms of CaCO3#
P4=400 #in terms of CaCO3#
P5=50 #in terms of CaCO3#
V=100000.0 #volume of water in litres#
#Calculation
L=0.74*(P2+P3+P4+P5)*V #lime required in mg#
L=L/10.0**6
S=1.06*(P1+P2+P5-P4)*V #soda required in mg#
S=S/10.0**6
#Result
print"Lime required is ",L,"kg"
print"\nSoda required is ",S,"kg"
```

In [15]:

```
#Variable declaration
W=50 #amount of NaCl in g/l in NaCl solution#
V=200 #volume of NaCl solution in litres#
#Calculation
A=W*V
V=10000 #volume of hard water passed through Zeolite softener#
M=100/(58.5*2) #multiplication factor of NaCl#
P=M*A
B=P*1000/V
#Result
print"\nIn terms of CaCO3=",round(P),"g CaCO3"
print"\nFor 1 litre of hard water=",round(B,1),"mg/l or ppm"
print"NOTE:In book answer wrongly written as 845.7"
```

In [16]:

```
#Variable declaration
W1=0.28 #amount of CaCO3 in grams dissolved in 1 litre of water#
V1=28 #required EDTA in ml on titration of 100ml of CaCO3 solution#
V2=33 #required EDTA in ml for 100ml of unknown hard water sample#
V3=10 #required EDTA in ml for 100 ml of unknown sample after boiling and cooling#
M1=100/100 #multiplication factor of CaCO3#
#Calculation
C=W1*M1
A=C*100#for 100 ml of sample equivalent to 28 ml of EDTA#
B=A/V1
D=V2*B #for 100 ml#
D=D*1000/100
E=V3*B #for 100 ml#
E=E*1000/100
T=D-E
#Result
print"Total hardness is ",D,"mg CaCO3 eq"
print"\nPermanant hardness is ",E,"mg CaCO3 eq"
print"\nTemporary hardness is ",T,"mg CaCO3"
```