In [42]:

```
#Variable declaration
OH=0.0025 # [OH-] ion concentration, M
Kw=1*10**-14 # ionic product of water, M**2
#Calculation
H=Kw/OH # From the formula (ionic product)Kw=[H+]*[OH-]
#Result
print"The [H+] ion concentration of the solution is :",H,"M"
```

In [43]:

```
import math
#Variable declaration
H1=3.2*10**-4 #Concentration of [H+] ion on first occasion,
H2=1*10**-3 #Concentration of [H+] ion on second occasion, M
#Calculation
pH1=-math.log10(H1) #from the definition of pH
pH2=-math.log10(H2) #from the definition of pH
#Result
print"pH of the solution on first occasion is:",round(pH1,2)
print"pH of the solution on second occasion is :",pH2
```

In [23]:

```
#Variable declaration
pH=4.82 #Given
#Calculation
H=10**(-pH) #Concentration of [H+] ion, M, formula from the definition of pH
#Result
print"The [H+] ion concentration of the solution is :%.1e"%H,"M"
```

In [44]:

```
import math
#Variable declaration
OH=2.9*10**-4 #Concentration of [OH-] ion, M
#Calculation
pOH=-math.log10(OH) #by definition of p(OH)
pH=14-pOH
#Result
print"\t the pH of the solution is :",round(pH,2)
```

In [45]:

```
import math
#Variable declaration
ConcHCl=1*10**-3 #Concentration of HCl solution, M
ConcBaOH2=0.02 #Concentration of Ba(OH)2 solution, M
#Calculation
#for HCL solution
H=ConcHCl #Concentration of [H+] ion after ionisation of HCl
pH=-math.log10(H)
#for Ba(OH)2 solution
OH=ConcBaOH2*2 #Concentration of [OH-] ion after ionisation of Ba(OH)2 as two ions are generated per one molecule of Ba(OH)2
pOH=-math.log10(OH)
pH2=14-pOH
#Result
print"(a). The pH of the HCl solution is :",pH
print"(b). The pH of the Ba(OH)2 solution is :",round(pH2,2)
```

In [47]:

```
import math
#Variable declaration
InitHNO2=0.036 #Initial concentration of HNO2 solution, M
#Let 'x' be the equilibrium concentration of the [H+] and [NO2-] ions, M
Ka=4.5*10**-4 #ionisation constant of HNO2, M
#Calculation
x=math.sqrt(Ka*InitHNO2) #from the definition of ionisation constant Ka=[H+]*[NO2-]/[HNO2]=x*x/(0.036-x), which reduces to x*x/0.036, as x<<InitHNO2 (approximation)
approx=x/InitHNO2*100 #this is the percentage of approximation taken. if it is more than 5%, we will be having higher deviation from correct value
if(approx>5):
x1=(-Ka+math.sqrt((Ka**2)-(-4*1*Ka*InitHNO2)))/(2*1)
x2=(-Ka-math.sqrt((Ka**2)-(-4*1*Ka*InitHNO2)))/(2*1)
if(x1>0):
x=x1
else :
x=x2
pH=-math.log10(x) #since x is the conc. of [H+] ions
#Result
print"The pH of the HNO2 solution is :",round(pH,2)
```

In [3]:

```
#Variable declaration
pH=2.39 # pH of the HCOOH acid solution
InitHCOOH=0.1 #initial concentration of the solution
#Calculation
H=10**(-pH) #[H+] ion concentration from the definition of pH, M
HCOO_=H #[HCOO-] ion concentration,M
HCOOH=InitHCOOH-H #HCOOH concentration in M
Ka=(H*HCOO_)/(HCOOH) #ionisation constant of the acid, M, Ka=[H+]*[HCOO-]/[HCOOH]
#Result
print"The ionisation constant of the given solution is :%.2e"%Ka,"M(approx)"
```

In [49]:

```
import math
#Variable declaration
InitNH3=0.4 #Initial concentration of NH3 solution, M
#Let 'x' be the equilibrium concentration of the [OH-] and [NH4+] ions, M
Kb=1.8*10**-5 #ionisation constant of NH3, M
#Calculation
x=math.sqrt(Kb*InitNH3) #from the definition of ionisation constant Kb=[OH-]*[NH4+]/[NH3]=x*x/(InitNH3-x), which reduces to x*x/InitNH3, as x<<InitNH3 (approximation)
approx=x/InitNH3*100 #this is the percentage of approximation taken. if it is more than 5%, we will be having higher deviation from correct value
if(approx>5):
x1=(-Kb+math.sqrt((Kb**2)-(-4*1*Kb*InitNH3)))/(2*1)
x2=(-Kb-math.sqrt((Kb**2)-(-4*1*Kb*InitNH3)))/(2*1)
if(x1>0):#as only one root is positive
x=x1
else:
x=x2
pOH=-math.log10(x) #since x is the conc. of [H+] ions
pH=14-pOH
#Result
print"The pH of the NH3 solution is :",round(pH,2)
```

In [10]:

```
#Variable declaration
InitC2H2O4=0.1 #Initial concentration of C2H2O4 solution, M
#Let 'x1' be the equilibrium concentration of the [H+] and [C2HO4-] ions, M
#First stage of ionisation
import math
Kw=10**-14 #ionic product of water, M**2
Ka1=6.5*10**-2 #ionisation constant of C2H2O4, M
#Calculation
x=math.sqrt(Ka1*InitC2H2O4) #from the definition of ionisation constant Ka1=[H+]*[C2HO4-]/[C2H2O4]=x*x/(InitC2H2O4-x), which reduces to x*x/InitC2H2O4, as x<<InitC2H2O4 (approximation)
approx=x/InitC2H2O4*100 #this is the percentage of approximation taken. if it is more than 5%, we will be having higher deviation from correct value
if(approx>5):
x1=(-Ka1+math.sqrt((Ka1**2)-(-4*1*Ka1*InitC2H2O4)))/(2*1)
x2=(-Ka1-math.sqrt((Ka1**2)-(-4*1*Ka1*InitC2H2O4)))/(2*1)
if(x1>0):#as only one root is positive
x=x1
else:
x=x2
C2H2O4=InitC2H2O4-x #equilibrium value
#Result
print"The concentration of the [H2C2O4] in the solution is :",round(C2H2O4,3),"M"
#Second stage of ionisation
#Variable declaration
InitC2HO4=x #concentration of C2HO4 from first stage of ionisation
Ka2=6.1*10**-5 #ionisation constant of C2HO4-, M
#Calculation
#Let 'y' be the concentration of the [C2HO4-] dissociated to form [H+] and [C2HO4-] ions, M
y=Ka2 #from the definition of ionisation constant Ka2=[H+]*[C2O4-2]/[C2HO4-]=(0.054+y)*y/(0.054-y), which reduces to y, as y<<InitC2HO4 (approximation)
approx=y/InitC2HO4*100 #this is the percentage of approximation taken. if it is more than 5%, we will be having higher deviation from correct value
if(approx>5):
x1=(-Ka2+math.sqrt((Ka2**2)-(-4*1*Ka2*InitC2HO4)))/(2*1)
x2=(-Ka2-math.sqrt((Ka2**2)-(-4*1*Ka2*InitC2HO4)))/(2*1)
if(x1>0):#as only one root is positive
y=x1
else:
y=x2
C2HO4=InitC2HO4-y #from first and second stages of ionisation
H=x+y #from first and second stages of ionisation
C2O4=y #from the assumption
OH=Kw/H # From the formula (ionic product)Kw=[H+]*[OH-]
#Result
print"The concentration of the [HC2O4-] ion in the solution is :",round(C2HO4,3),"M"
print"The concentration of the [H+] ion in the solution is :",round(H,3),"M"
print"The concentration of the [C2O4^2-] ion in the solution is :",C2O4,"M"
print"The concentration of the [OH-] ion in the solution is :%.1e"%OH,"M"
```

In [51]:

```
#Variable declaration
InitCH3COONa=0.15 #Initial concentration of CH3COONa solution, M
InitCH3COO=InitCH3COONa #concentration of [CH3COO-] ion after dissociation of CH3COONa solution, M
#Let 'x' be the equilibrium concentration of the [OH-] and [CH3COOH] ions after hydrolysis of [CH3COO-], M
Kb=5.6*10**-10 #equilibrium constant of hydrolysis, M
import math
#Calculation
x=math.sqrt(Kb*InitCH3COO) #from the definition of ionisation constant Kb=[OH-]*[CH3COOH]/[CH3COO-]=x*x/(0.15-x), which reduces to x*x/0.15, as x<<0.15 (approximation)
approx=x/InitCH3COO*100 #this is the percentage of approximation taken. if it is more than 5%, we will be having higher deviation from correct value
if(approx>5):
x1=(-Kb+math.sqrt((Kb**2)-(-4*1*Kb*InitCH3COO)))/(2*1)
x2=(-Kb-math.sqrt((Kb**2)-(-4*1*Kb*InitCH3COO)))/(2*1)
if(x1>0):#as only one root is positive
x=x1
else:
x=x2
pOH=-math.log10(x) #since x is the conc. of [OH-] ions
pH=14-pOH
#Result
print"The pH of the salt solution is :",round(pH,2)
percenthydrolysis=x/InitCH3COO*100
print"The percentage of hydrolysis of the salt solution is :",round(percenthydrolysis,4),"%"
```