Chapter 2:Acids and Bases

Example no:1,Page no:38

In [1]:
#Variable declaration
OH=0.0025 #OH- concentration#
K=1*10**-14#water ionization constant#

#Calculation
H=K/OH 
H=H/10**-12 

#Result
print"The concentration of H+ ions is",H*10**-12,"M" 
 
print"\nAs concentration of H+ is lesser than the concentration of OH-(0.0025) the cleaning solution will be basic in nature" 
The concentration of H+ ions is 4e-12 M

As concentration of H+ is lesser than the concentration of OH-(0.0025) the cleaning solution will be basic in nature

Example no:2,Page no:40

In [2]:
#Variable declaration
pH=7.3 #pH value of human blood
H=10**-pH 

#Calculation
H1=H
k=1*10**-14 #water ionization constant
OH=k/H 
OH=OH

#Result
print"H+ concentration of human blood is %.e"%H1,"M" 
print"\nOH- concentration of human blood is %.3g"%OH,"M(in scientiifc form) or 0.2*10**-6 M" 
H+ concentration of human blood is 5e-08 M

OH- concentration of human blood is 2e-07 M(in scientiifc form) or 0.2*10**-6 M

Example no:3,Page no:41

In [3]:
import math
#Variable declaration
N1=0.2 #normality of HCl#
V1=25 #volume of HCl in ml#
M2=0.25 #molarity of NaOH#
N2=M2*1 #normality of NaOH#
V2=50 #volume of NaOH in ml#

#Calculation
V=V1+V2 #volume of resulting solution#
N=(N2*V2-N1*V1)/V #normality of resulting solution#

K=1*10**-14 #ionization constant of water#
H=K/N 
H1=H/10**-13 

pH=-math.log10(H) 

#Result

print"\npH of the mixure will be",pH
pH of the mixure will be 13.0

Example no:4,Page no:44

In [4]:
#Variable declaration
S=0.2 #salt concentration#
A=0.2 #acid concentration#
k=1.8*10**-5 #dissociation constant of acetic acid#

import math

#Calculation
pH=-math.log10(k)+math.log10(S/A) 
v=1*10**-3 #amount of HCl added in lit#
M=1 #molarity of HCl added#
n=v*M #no of moles of HCl added per litre#
A1=A+n 
S1=S-n 
pH2=-math.log10(k)+math.log10(S1/A1) 
p=pH-pH2 

#Result
print"pH of the buffer solution before adding HCl is",round(pH ,4)

print"\npH of the buffer solution after adding HCl is",round(pH2,3)
print"\nAns: Change in pH is",round(p,3)
pH of the buffer solution before adding HCl is 4.7447

pH of the buffer solution after adding HCl is 4.74

Ans: Change in pH is 0.004

Example no:2.1,Page no:46

In [5]:
#(a)#
#Variable declaration
N1=1.0/1000.0 #normality of HCl#
a=100.0 #percentage of ionization#
import math

#Calculation
C1=N1*a/100.0 
pH1=-math.log10(C1) 
N2=1.0/10000.0 #normality of NaOH solution#
C2=N2*a/10.0 
C2a=C2/10.0**-4 
k=10.0**-14 #dissociation constant of water#
H2=k/C2 
H2a=H2/10.0**-10 
pH2=-math.log10(H2) 
N3=1.0/1000.0 #normality of NaOH solution#
C3=N3*a/1000.0 
C3a=C3/10.0**-3 
H3=k/C3 
H3a=H3/10.0**-11 
pH3=-math.log10(H3) 

#Result
print"Ans(a)\n(i)\tThe pH of N/1000 HCl solution is",pH1 
print"\n(ii)\tThe pH of the N/10000 solution is",pH2 
print"\n(iii)\tThe pH of the N/1000 solution is",pH3




#(b)#
#Variable declaration
N=0.1 #normality of given weak base#
pH=9.0 #pH of the base#
H=10.0**(-pH) 
Ha=H/10.0**-9

#Calculation
OH=k/H 
OHa=OH/10.0**-5 
a1=OH/N 
a1b=a1

#Result
print"\nAns(b)\nDegree of ionization of given weak base is",a1b,"=",a1b*100,"%"
Ans(a)
(i)	The pH of N/1000 HCl solution is 3.0

(ii)	The pH of the N/10000 solution is 11.0

(iii)	The pH of the N/1000 solution is 10.0

Ans(b)
Degree of ionization of given weak base is 0.0001 = 0.01 %

Example no:2.2,Page no:47

In [6]:
#Variable declaration
N=0.002 #normality of acetic acid solution#
a=2.3 #percentage of ionization#
import math

#Calculation
H=N*a/100.0 #concentration of H+ ion#
pH=-math.log10(H) 

#Result
print"\nAns(a)\n pH value of acid solution is",round(pH,4)



#Part b(b)#

#Variable declaration
N1=0.01 #normality of acetic acid solution#
a1=60.0 #percentage of ionization#
#ii#
N2=0.1 #normality of acetic acid solution#
a2=1.8 #percentage of ionization#
#iii#
N3=0.04 #normality of HNO3#
a3=100.0 #percentage of ionization#
#iv#
W=4.0 #weight of NaOH dissolved in water in grams#
EW=40.0 #equivalent weight weight of NaOH#


#Calculation
#i#
H1=N1*a1/100.0 #concentration of H+ ion#
pH1=-math.log10(H1) 
#ii#
H2=N2*a2/100.0 #concentration of H+ ion#
pH2=-math.log10(H2) 
#iii#
H3=N3*a3/100.0 
pH3=-math.log10(H3) 
N4=0.0001 #normality of Hcl#
a4=100.0 #percentage of ionization#
H4=N4*a4/100.0 
pH4=-math.log10(H4) 
N5=1.0 #normality of Hcl#
a5=100.0 #percentage of ionization#
H5=N5*a5/100.0 
pH5=-math.log10(H5) 
N6=0.1 #normality of HNO3#
a6=100.0 #percentage of ionization#
OH6=N6*a6/100.0 
Kw=10.0**-14 
H6=Kw/OH6 
pH6=-math.log10(H6)
N7=0.001 #normality of NaOH#
a7=100.0 #percentage of ionization#
OH7=N7*a7/100.0 
Kw=10.0**-14 
H7=Kw/OH7 
pH7=-math.log10(H7) 
#iv#
N8=W/EW 
a8=100.0 #percentage of ionization#
OH8=N8*a8/100.0 
Kw=10.0**-14 
H8=Kw/OH8 
pH8=-math.log10(H8) 


#Result
print'\nAns(b)\n(i)   pH value of  0.01N acid solution is',round(pH1,4)

print"\n(ii)  pH value of decinormal acid solution is",round(pH2 ,4)

print"\n(iii) The pH of 0.04N HNO3 solution is",round(pH3,3)
print"\n      The pH of 0.0001N Hcl solution is",pH4 
print"\n      The pH of 1N Hcl solution is",pH5 
print"\n      The pH of 0.1N NaOH solution is ",pH6
print"\n      The pH of 0.01N NaOH solution is",pH7

print"\n(iv)  The pH of solution containing 4g NaoH solution is ",pH8 
Ans(a)
 pH value of acid solution is 4.3372

Ans(b)
(i)   pH value of  0.01N acid solution is 2.2218

(ii)  pH value of decinormal acid solution is 2.7447

(iii) The pH of 0.04N HNO3 solution is 1.398

      The pH of 0.0001N Hcl solution is 4.0

      The pH of 1N Hcl solution is -0.0

      The pH of 0.1N NaOH solution is  13.0

      The pH of 0.01N NaOH solution is 11.0

(iv)  The pH of solution containing 4g NaoH solution is  13.0

Example no:2.3,Page no:48

In [16]:
import math

#Variable declaration
N1=0.1 #normality of acetic acid#
a1=1.3 #percentage of ionization#
M1=10**-8 #molarity of hcl solution#
a=100 #percentage of ionization#
N2=0.05 #normality of Hcl#
a2=100 #percentage of ionization#

#Calculation
#(a)#
H1=N1*a1/100 
#(b)#
H=M1*a/100 
pH=-math.log10(H) 
#(c)#
pH2=-math.log10(N2*a2/100) 
M3=0.05 #molarity os H2SO4#
a3=100 #percentage of ionization#
pH3=-math.log10(M3*a3/100.0) 

#Result
print"(a).The hydrogen ion concentration of solution is %.2e"%H1,"g.ion/lit"
print'\n(b).The pH of the Hcl solution is',pH
print"Theoretically the pH should be 8,however,the value will be close to 7 because H+ ions of water also plays a role"
print"\n(c).The pH of 0.05 Hcl solution is",round(pH2,3)
print"The pH of 0.05M H2SO4 solution is",round(pH3,3)
(a).The hydrogen ion concentration of solution is 1.30e-03 g.ion/lit

(b).The pH of the Hcl solution is 8.0
Theoretically the pH should be 8,however,the value will be close to 7 because H+ ions of water also plays a role

(c).The pH of 0.05 Hcl solution is 1.301
The pH of 0.05M H2SO4 solution is 1.301

Example no:2.4,Page no:49

In [1]:
import math

#Variable declaration
H1=0.005 #H+ ion concentration of solution in g.ion/lit#
H2=3*10**-4 #H+ concentration of the solution#
k=10**-14 #dissociation constant of water#
OH3=0.1#hydroxyl concentration of a solution#
k4=1.8*10**-5#dissociation constant of acetic acid at 180C#
N4=0.1 #normality of acetic acid#
N5=0.01 #normality of acetic acid#
N6=0.001 #normality of acetic acid#

#Calculation

#Part-a#
pH1=-math.log10(H1) 

#Part-b#
pH2=-math.log10(H2) 
pOH2=14-pH2 
OH2=k/H2

#Part-c#
H3=k/OH3 
pH3=-math.log10(H3) 
V4=1/N4 

#Part-d#
a4=math.sqrt(k4*V4) #formula for degree of dissociation#
H4=N4*a4 #H+ ion concentration#
pH4=-math.log10(H4) 
V5=1/N5 
a5=sqrt(k4*V5) #formula for degree of dissociation#
H5=N5*a5 #H+ ion concentration#
pH5=-math.log10(H5) 
V6=1/N6 
a6=sqrt(k4*V6) #formula for degree of dissociation#
H6=N6*a6 #H+ ion concentration#
pH6=-math.log10(H6) 


#Result
print"\n\n(a)  The pH value of solution whose H+ ion concentration is 0.005g.ion/lit is",round(pH1 ,3)
print"\n(b)  The pH of a solution in which H+ is 3*10**-4 is",round(pH2 ,2)
print"\n     pOH of the solution is",round(pOH2,2)
print"\n     OH- concentration for a solution is%.1e"%OH2,"M"
print"\n(c)  pH of the solution whose hydroxyl concentration is N/10g.ion/lit is",pH3
print"\n(d)  pH of 0.1N acetic acid solution is",round(pH4,3)
print"\n     pH of 0.01N acetic acid solution is",round(pH5,4)
print"\n     pH of 0.001N acetic acid solution is",round(pH6,4)

(a)  The pH value of solution whose H+ ion concentration is 0.005g.ion/lit is 2.301

(b)  The pH of a solution in which H+ is 3*10**-4 is 3.52

     pOH of the solution is 10.48

     OH- concentration for a solution is3.3e-11 M

(c)  pH of the solution whose hydroxyl concentration is N/10g.ion/lit is 13.0

(d)  pH of 0.1N acetic acid solution is 2.872

     pH of 0.01N acetic acid solution is 3.3724

     pH of 0.001N acetic acid solution is 3.8724

Example no:2.5,Page no:51

In [9]:
import math

#Variable declaration
K1=10.0**-8 #dissociation constant of weak mono basic acid#
N1=0.01 #normality of the acid#
a2=4.0/100.0 #percentage of dissociation of acid at 20C#
N2=0.1 #normality of acid#
N3=0.1 #normality of HCl#
N4=1.0/50.0 #normality of HCl#
N5=0.01 #normality of H2SO4#

#Calculation
#Part-a#
V1=1.0/N1 
a1=math.sqrt(K1*V1) #degree of dissociation for weak acids#
H1=N1*a1 #H+ concentration of the solution#
pH1=-math.log10(H1) 
#Part-b#
V2=1.0/N2 
K2=(a2**2)/V2 
#Part-c#
pH3=-math.log10(N3) 
pH4=-math.log10(N4) 
pH5=-math.log10(N5) 

#Result
print"(a)  pH value of 0.01N solution of a weak mono basic acid is",pH1 
print"\n(b) The dissociation constant of the acid is  %.1e"%K2
print"\n(c) The pH of the 0.1N HCl solution is",pH3
print"\n    The pH of the 1/50N HCl solution is",round(pH4,1)
print"\n    The pH of the 0.01N H2SO4 solution is ",pH5
(a)  pH value of 0.01N solution of a weak mono basic acid is 5.0

(b) The dissociation constant of the acid is  1.6e-04

(c) The pH of the 0.1N HCl solution is 1.0

    The pH of the 1/50N HCl solution is 1.7

    The pH of the 0.01N H2SO4 solution is  2.0

Example no:2.6,Page no:52

In [10]:
#Variable declaration
V1=50.0 #volume of Hcl in ml#
V2=30.0 #volume of NaOH in ml#
N1=1.0 #normality of Hcl#
N2=1.0 #nomality of NaOH#
import math

#Calculation
V=V1+V2 #total volume of mixure of solutions#
a=100.0 #percentage of ionization#
N=(N1*V1-N2*V2)/V 
H=N*a/100 
pH=-math.log10(H) 

#Result

print'\nThe pH of resultant solution is',round(pH,3)
The pH of resultant solution is 0.602

Example no:2.7,Page no:52

In [11]:
#Variable declaration
N1=1.0/10.0 #normality of NaOH#
N2=1.0/20.0 #normality of HCl#
V1=1.0 #volume of NaOH in lit#
V2=1.0 #volume of HCl in lit#
import math

#Calculation
V=V1+V2 #volume of resultant solution#
N=(N1*V1-N2*V2)/V 
k=1.0*10.0**-14 #ionization constant of water#
H1=k/N 
H=H1/10.0**-13 
pH=-math.log10(H1)

#Result
print"\npH of the solution is",round(pH,1)
pH of the solution is 12.4

Example no:2.8,Page no:53

In [12]:
#Variable declaration
W=2.0 #weight of NaOH dissolved in water in grams#
M=40.0 #molecular weight of NaOH#
N=W/M #normality#
a=100.0 #percentage of ionization#
import math

#Calculation
OH=N*a/100.0 #the OH- ion concentration of solution#
Kw=10.0**-14 
H=Kw/OH 
pH=-math.log10(H) 

#Result
print'\n The pH of the NaOH solution is',round(pH,1)
 The pH of the NaOH solution is 12.7

Example no:2.9,Page no:53

In [13]:
#Variable declaration
M=0.001 #molarity of benzoic acid#
N=M #normality of benzoic acid#
import math

#Calculation
V=1/N 
K=7.3*10**-5 #dissociation constant of benzoic acid#
a=math.sqrt(K*V) #since benzoic acid is very weak#

#Result
H=N*a 
print"\n The H+ concentration of the solution is%.3e"%H,"g.ion/litre"
 The H+ concentration of the solution is2.702e-04 g.ion/litre

Example no:2.10,Page no:53

In [14]:
#Variable declaration
W=0.092 #weight of Formic acid per litre in grams#
M=46 #molecular weight of Formic acid#
import math

#Calculation
N=W/M 
V=1/N 
K=2.4*10**-4 #Dissociation constant of Formic acid at 25C#
a=math.sqrt(K*V) #For weak acids#

#Result
H=a*N 
print'\n The H+ concentration of the solution is %.3e'%H
 The H+ concentration of the solution is 6.928e-04

Example no:2.11,Page no:54

In [15]:
import math

#Variable declaration
k=2.5*10**-5 #dissociation constant of NH4OH#
N=1.0/100.0 #normality of NH4OH#
V=100
#Calculation
C=N #since volume of solution is one litre#
NH=C 
NHOH=C 
OH1=k*NHOH/NH 
a=math.sqrt(k*V)

#Result
print"Cong of OH- ions in solution is",a*N,"g ion per litre"
print"\nWhen 1/100 part of a g mol NH4Cl are dissolverd in a litre ,then ,\nHydroxyl ion concentration in the solution is",OH1
Cong of OH- ions in solution is 0.0005 g ion per litre

When 1/100 part of a g mol NH4Cl are dissolverd in a litre ,then ,
Hydroxyl ion concentration in the solution is 2.5e-05

Example no:2.12,Page no:56

In [16]:
#Variable declaration
K=1.7*10**-5 #Dissociation constant of NH4OH#
N=0.01 #Normality of NH4OH solution#

import math

#Calculation
V=1.0/N 
a=math.sqrt(K*V) #since a is very small#
OH=a*N 

NH4=0.05 #concentration of NH4+ in g.ion/lit#
NH4OH=0.01 #concentration of NH4OH in g.mol/lit#
OH2=K*NH4OH/NH4 
#Result
print"\nConcentration of OH- ions before addition of NH4Cl is %.2e"%OH,"g.ion/litre"
print"\nThe concentration of hydroxyl ions after adding NH4Cl is",OH2,"g.ion/litre"
Concentration of OH- ions before addition of NH4Cl is 4.12e-04 g.ion/litre

The concentration of hydroxyl ions after adding NH4Cl is 3.4e-06 g.ion/litre

Example no:2.13,Page no:56

In [17]:
#Variable declaration
k=1.8*10**-5 #dissociation constant of acetic acid at 18C#
N=0.25 #normality of acetic acid solution#
N2=0.25#normality os sodium acetate added#
import math

#Calculation
#Part-a#
V=1/N 
a=math.sqrt(k*V) #formula of degree of dissociation for weak acids#
H=N*a 
#Part-b#
CH3COO=N2 
CH3COOH=N2 
H2=k*CH3COOH/CH3COO 
H3=H2/10**-5 
a2=H2/N2 
a3=a2/10**-5 


#Result
print"(a)  0.25 N acetic acid solution---"
print"\tDegree of dissociation of acetic acid is %.3e"%a
print"\tH+ concentration of the solution is %.3e"%H,"g.ion/litre"

print"\n(b)  0.25 N acetic acid solution containing 0.25N sodium acetate----"
print"\tH+ ion concentration after adding sodium acetate is",H3*10**-5
print"\tDegree of dissociation after adding sodium acetate is",a3*10**-5
(a)  0.25 N acetic acid solution---
	Degree of dissociation of acetic acid is 8.485e-03
	H+ concentration of the solution is 2.121e-03 g.ion/litre

(b)  0.25 N acetic acid solution containing 0.25N sodium acetate----
	H+ ion concentration after adding sodium acetate is 1.8e-05
	Degree of dissociation after adding sodium acetate is 7.2e-05

Example no:2.14,Page no:57

In [18]:
#Variable declaration
C1=0.06 #concentration od acetic acid in g.mol/lit#
C2=0.04 #concentration of sodium acetate in g.mol/li#
K=1.8*10**-5 #dissociation constant of acetic acid#
import math

#Calculation
H=K*C1/C2 
pH=-math.log10(H) 

#Result
print"\nThe pH of solution is",round(pH,4)
The pH of solution is 4.5686

Example no:2.15,Page no:58

In [19]:
#Variable declaration
M1=0.2 #molarity of acetic acid#
M2=0.2 #molarity of sodium acetate#
K=1.8*10**-5 
import math

#Calculation
pH=-math.log10(K)+math.log10(M2/M1) #by using Henderson's equation#

#Result
print"The pH value of buffer solution is",round(pH,4)
The pH value of buffer solution is 4.7447

Example no:2.16,Page no:58

In [20]:
#Variable declaration
N=1.0/100.0 #normality of acetic acid#
V=1.0/N 
k=1.8*10**-5 #dissociation constant of acetic acid#
import math

#Calculation

#Part-a#
a=math.sqrt(k*V) #formula of degree of dissociation for weak acids#
H=a*N 

#Part-b#
n=0.01 #sodium acetate added in moles to one litre of acetic acid solution#
CH3COO=n 
CH3COOH=n 
H1=k*CH3COOH/CH3COO 


#Result
print"(a)  H+ concentration of N/100 acetic acid solution is %.2e"%H,"g ion/litre"
print"\n(b)  H+ ion concentration in the solution after adding the sodium acetate is",H1,"g.ions/litre"
(a)  H+ concentration of N/100 acetic acid solution is 4.24e-04 g ion/litre

(b)  H+ ion concentration in the solution after adding the sodium acetate is 1.8e-05 g.ions/litre

Example no:2.17,Page no:59

In [21]:
#Variable declaration
V=10 #volume of water in litres#
N1=0.10 #moles of HCN added in solution#
N2=0.10 #moles of NaCN added in solution#
K=7.2*10**-10 #dissociation constant of HCN#
CN=0.1 #CN- concentration#
HCN=0.1 #HCN concentration#

#Calculation
H1=K*HCN/CN 
H=H1/10**-10 
k=1*10**-14 #ionization constant of water#

#Result
print"H+ concentration in the solution is",H*10**-10
OH=k/H1 
print"\nOH- concentration in the solution is %.1e"%OH
H+ concentration in the solution is 7.2e-10

OH- concentration in the solution is 1.4e-05

Example no:2.18,Page no:59

In [22]:
#Variable declaration
K=1.7*10**-5 #dissociation constant of acid#
pH=3.77#pH value of buffer solution#
import math

#Calculation
M=pH+math.log10(K) 
N=10**M #ratio of salt to acid#
L=1/N

#Result
print"The ratio of salt to acid in buffer is",round(L)
The ratio of salt to acid in buffer is 10.0

Example no:2.19,Page no:59

In [24]:
#Variable declaration
k=1.8*10**-5 #dissociation constant of acetic acid#
M=0.01 #molarity of acetic acid#
N=M*1 #normality of acetic acid#
import math

#Calculation
V=1/N 
a=math.sqrt(k*V)#degree of dissociation for weak acids#
H1=a/V 
H=H1/10**-4 
pH=-math.log10(H1) 

#Result
print"Degree of dissociation of solution is %.2e"%a 
print"pH of the solution is",round(pH ,4)
Degree of dissociation of solution is 4.24e-02
pH of the solution is 3.3724

Example no:2.20,Page no:60

In [25]:
#Variable declaration
N1=0.2#concentration of acetic acid in g.molecule/lit#
N2=0.25#concentration of sodium acetate in g.molecule/lit#
K=1.8*10**-5#ionization constant of acetic acid at room temparature#
import math

#Calculation
pH1=-math.log10(K)+math.log10(N2/N1) 
N=1.0#normality of HCl added#
V=0.5*10**-3#amount of HCl added in lit#
M=N*V
C1=N1+M#concentration of CH3COOH in moles/lit#
C2=N2-M#concentration of CH3COONa in moles/lit#
pH2=-math.log10(K)+math.log10(C2/C1)
pH=pH1-pH2 

#Result
print"pH value of the solution before adding HCl is",round(pH1,4)
print"\nThe pH of the solution after adding HCl is",round(pH2,4)
print"\nThe change of pH is",round(pH,4)
pH value of the solution before adding HCl is 4.8416

The pH of the solution after adding HCl is 4.8397

The change of pH is 0.002

Example no:2.21,Page no:61

In [27]:
#Variable declaration
K=18*10**-6 #dissociation constant of NH4OH#
N1=0.1 #normality of NH4OH solution#
V=1.0/N1 
import math

#Calculation
a=math.sqrt(K*V)#since a is very small#
OH=a/V 
W=2.0#weight of added NH4Cl in grams#
M=53.0#molecular weight of NH4Cl#
C=W/M 
C1=0.1 #concentration of NH4OH in g.mol/lit#
OH2=K*C1/C
CH3COO=0.02              #g ion per litre
CH3COOH=0.2              #g mol per litre
H_plus=K*CH3COOH/CH3COO
pH=math.log10(H_plus)


#Result
print"\nThe concentration of hydroxyl ion before adding of NH4Cl is %.3e"%OH,"g ion per litre"
print"\nThe concentration of hydroxyl ion after adding 2g of NH4Cl is %.1e"%OH2,"g ion per litre"
print"NOTE:Calculation mistake in book.(wrongly written as 48.6*10**-5,it should be 10**-6"
print "\npH is",round(-pH,4)
The concentration of hydroxyl ion before adding of NH4Cl is 1.342e-03 g ion per litre

The concentration of hydroxyl ion after adding 2g of NH4Cl is 4.8e-05 g ion per litre
NOTE:Calculation mistake in book.(wrongly written as 48.6*10**-5,it should be 10**-6

pH is 3.7447

Example no:2.22,Page no:62

In [28]:
#Variable declaration
ly=11.92 #equivalent conductvity of 0.02acetic acid solution in mho at 20C#
lih=360 #the equivalent ionic conductance of an infinite dillution of hydrogen ion in mho#
lic=40 #of acetate ion#
li=lih+lic #of acetic acid#
import math

#Calculation
a=ly/li #degree of dissociation#
N=0.02 #normality of acetic acid#
V=1/N 
K=(a**2)/V 
W=82 #mol.wt of CH3COONa#
M=8.2#amount of sodium acetate added in g per litre solution#
CH3COO=M/W 
H=K*N/CH3COO 
pH=-math.log10(H) 

#Result
print"Dissociation constant of acetic acid is %.2e"%K
print"\npH of the solution is",round(pH,2)
print"\nNOTE:\n(i)Calculation  istake in calculation of K in book,exponent wrongly written as -6"
print"(ii)pH is wrongly calculated in book as 3.45"
Dissociation constant of acetic acid is 1.78e-05

pH of the solution is 5.45

NOTE:
(i)Calculation  istake in calculation of K in book,exponent wrongly written as -6
(ii)pH is wrongly calculated in book as 3.45