#calculate the equlibrium pH
#Initialization of variables
ph1=6.37
ph2=10.25
ph3=7.21
ph4=12.67
#calculations
pH1=0.5*(ph1+ph2)
pH2=0.5*(ph3+ph4)
#results
print '%s %.2f' %("Equilibrium pH in case 1 = ",pH1)
print '%s %.2f' %("\n Equilibrium pH in case 2 = ",pH2)
#calculate the pH of the solution
#Initialization of variables
import math
n=2.5/1000. #mol
C=0.2 #mol/L
vbase=37.5/1000. #L
#calculations
V=n/C
base=n/vbase
H=math.pow(10,-14) /base
print '%s' %("It follows from example 8.2 that")
pH=10.2
#results
print '%s %.1f' %("\n pH of the solution = ",pH)
#calculate the percent of acetic acid molecules that have donated a proton
#Initialization of variables
import math
C=0.15 #M
Ka=1.8*math.pow(10,-5)
#calculations
x=math.sqrt(C*Ka)
f=x/C
percent=f*100.
#results
print '%s %.1f %s' %("percent of acetic acid molecules that have donated a proton =",percent,"percent")
#calculate the fraction proportionated
#Initialization of variables
import math
pKa=4.88
C=0.01 #M
pKw=14
#calculations
pKb=pKw-pKa
Kb=math.pow(10,(-pKb))
x=(math.sqrt(C*Kb))
pOH=-math.log(x)
pH=14-pOH
f=x/C
#results
print '%s %.1e' %("fraction protonated = ",f)
print '%s %d' %("\n 1 molecule in about ",1./f)
#calculate te concentration of carbonate ions
#Initialization of variables
import math
pKa2=10.25
#calculations
C=math.pow(10,(-pKa2))
#results
print '%s %.1e %s' %("Concentration of Carbonate ions =",C," mol/l")
#calculate the final pH of the solution
#Initialization of variables
import math
vOH=5*math.pow(10,-3) #L
vHClO=25*math.pow(10,-3) #L
C=0.2 #mol/L
#calculations
nOH=vOH*C
nHClO=vHClO*C/2.
nrem=nHClO-nOH
pH=7.53-math.log10(nrem/nOH)
#results
print '%s %.1f' %("Final pH= ",pH)