{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 15:Acids and Bases"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:15.2,Page no:662"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "OH=0.0025  # [OH-] ion concentration, M\n",
      "Kw=1*10**-14  # ionic product of water, M**2\n",
      "#Calculation\n",
      "H=Kw/OH  # From the formula (ionic product)Kw=[H+]*[OH-]\n",
      "#Result\n",
      "print\"The [H+] ion concentration of the solution is :\",H,\"M\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The [H+] ion concentration of the solution is : 4e-12 M\n"
       ]
      }
     ],
     "prompt_number": 42
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:15.3,Page no:665"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "H1=3.2*10**-4  #Concentration of [H+] ion on first occasion,\n",
      "H2=1*10**-3  #Concentration of [H+] ion on second occasion, M\n",
      "\n",
      "#Calculation\n",
      "pH1=-math.log10(H1) #from the definition of pH\n",
      "pH2=-math.log10(H2) #from the definition of pH\n",
      "\n",
      "#Result\n",
      "print\"pH of the solution on first occasion is:\",round(pH1,2)\n",
      "print\"pH of the solution on second occasion is :\",pH2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "pH of the solution on first occasion is: 3.49\n",
        "pH of the solution on second occasion is : 3.0\n"
       ]
      }
     ],
     "prompt_number": 43
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:15.4,Page no:665"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "pH=4.82 #Given\n",
      "\n",
      "#Calculation\n",
      "H=10**(-pH) #Concentration of [H+] ion, M, formula from the definition of pH\n",
      "\n",
      "#Result\n",
      "print\"The [H+] ion concentration of the solution is :%.1e\"%H,\"M\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The [H+] ion concentration of the solution is :1.5e-05 M\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:15.5,Page no:666"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Variable declaration\n",
      "OH=2.9*10**-4 #Concentration of [OH-] ion, M\n",
      "#Calculation\n",
      "pOH=-math.log10(OH) #by definition of p(OH)\n",
      "pH=14-pOH \n",
      "#Result\n",
      "print\"\\t the pH of the solution is :\",round(pH,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\t the pH of the solution is : 10.46\n"
       ]
      }
     ],
     "prompt_number": 44
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:15.6,Page no:669"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "ConcHCl=1*10**-3 #Concentration of HCl solution, M\n",
      "ConcBaOH2=0.02 #Concentration of Ba(OH)2 solution, M\n",
      "\n",
      "#Calculation\n",
      "#for HCL solution\n",
      "H=ConcHCl #Concentration of [H+] ion after ionisation of HCl\n",
      "pH=-math.log10(H) \n",
      "#for Ba(OH)2 solution\n",
      "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\n",
      "pOH=-math.log10(OH) \n",
      "pH2=14-pOH \n",
      "\n",
      "#Result\n",
      "print\"(a). The pH of the HCl solution is :\",pH\n",
      "print\"(b). The pH of the Ba(OH)2 solution is :\",round(pH2,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a). The pH of the HCl solution is : 3.0\n",
        "(b). The pH of the Ba(OH)2 solution is : 12.6\n"
       ]
      }
     ],
     "prompt_number": 45
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:15.8,Page no:675"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Variable declaration\n",
      "InitHNO2=0.036 #Initial concentration of HNO2 solution, M\n",
      "#Let 'x' be the equilibrium concentration of the [H+] and [NO2-] ions, M\n",
      "Ka=4.5*10**-4 #ionisation constant of HNO2, M\n",
      "\n",
      "#Calculation\n",
      "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)\n",
      "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\n",
      "if(approx>5):\n",
      "     x1=(-Ka+math.sqrt((Ka**2)-(-4*1*Ka*InitHNO2)))/(2*1) \n",
      "     x2=(-Ka-math.sqrt((Ka**2)-(-4*1*Ka*InitHNO2)))/(2*1) \n",
      "     if(x1>0):\n",
      "         x=x1 \n",
      "     else :\n",
      "          x=x2 \n",
      "pH=-math.log10(x) #since x is the conc. of [H+] ions\n",
      "\n",
      "#Result\n",
      "print\"The pH of the HNO2 solution is :\",round(pH,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The pH of the HNO2 solution is : 2.42\n"
       ]
      }
     ],
     "prompt_number": 47
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:15.9,Page no:676"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "pH=2.39 # pH of the HCOOH acid solution\n",
      "InitHCOOH=0.1 #initial concentration of the solution\n",
      "\n",
      "#Calculation\n",
      "H=10**(-pH) #[H+] ion concentration from the definition of pH, M\n",
      "HCOO_=H     #[HCOO-] ion concentration,M\n",
      "HCOOH=InitHCOOH-H   #HCOOH concentration in M\n",
      "Ka=(H*HCOO_)/(HCOOH) #ionisation constant of the acid, M, Ka=[H+]*[HCOO-]/[HCOOH]\n",
      "\n",
      "#Result\n",
      "print\"The ionisation constant of the given solution is :%.2e\"%Ka,\"M(approx)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The ionisation constant of the given solution is :1.73e-04 M(approx)\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:15.10,Page no:678"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "InitNH3=0.4 #Initial concentration of NH3 solution, M\n",
      "#Let 'x' be the equilibrium concentration of the [OH-] and [NH4+] ions, M\n",
      "Kb=1.8*10**-5 #ionisation constant of NH3, M\n",
      "\n",
      "#Calculation\n",
      "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)\n",
      "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\n",
      "if(approx>5):\n",
      "     x1=(-Kb+math.sqrt((Kb**2)-(-4*1*Kb*InitNH3)))/(2*1) \n",
      "     x2=(-Kb-math.sqrt((Kb**2)-(-4*1*Kb*InitNH3)))/(2*1) \n",
      "     if(x1>0):#as only one root is positive\n",
      "          x=x1 \n",
      "     else:\n",
      "          x=x2 \n",
      "pOH=-math.log10(x) #since x is the conc. of [H+] ions\n",
      "pH=14-pOH \n",
      "\n",
      "#Result\n",
      "print\"The pH of the NH3 solution is :\",round(pH,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The pH of the NH3 solution is : 11.43\n"
       ]
      }
     ],
     "prompt_number": 49
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:15.11,Page no:682"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "InitC2H2O4=0.1 #Initial concentration of C2H2O4 solution, M\n",
      "#Let 'x1' be the equilibrium concentration of the [H+] and [C2HO4-] ions, M\n",
      "#First stage of ionisation\n",
      "import math\n",
      "Kw=10**-14 #ionic product of water, M**2\n",
      "Ka1=6.5*10**-2 #ionisation constant of C2H2O4, M\n",
      "\n",
      "#Calculation\n",
      "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)\n",
      "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\n",
      "if(approx>5):\n",
      "     x1=(-Ka1+math.sqrt((Ka1**2)-(-4*1*Ka1*InitC2H2O4)))/(2*1) \n",
      "     x2=(-Ka1-math.sqrt((Ka1**2)-(-4*1*Ka1*InitC2H2O4)))/(2*1) \n",
      "     if(x1>0):#as only one root is positive\n",
      "          x=x1 \n",
      "     else: \n",
      "          x=x2 \n",
      "C2H2O4=InitC2H2O4-x #equilibrium value\n",
      "\n",
      "#Result\n",
      "print\"The concentration of the [H2C2O4] in the solution is :\",round(C2H2O4,3),\"M\"\n",
      "\n",
      "\n",
      "#Second stage of ionisation\n",
      "\n",
      "#Variable declaration\n",
      "InitC2HO4=x #concentration of C2HO4 from first stage of ionisation\n",
      "Ka2=6.1*10**-5 #ionisation constant of C2HO4-, M\n",
      "\n",
      "#Calculation\n",
      "#Let 'y' be the concentration of the [C2HO4-] dissociated to form [H+] and [C2HO4-] ions, M\n",
      "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)\n",
      "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\n",
      "if(approx>5):\n",
      "     x1=(-Ka2+math.sqrt((Ka2**2)-(-4*1*Ka2*InitC2HO4)))/(2*1) \n",
      "     x2=(-Ka2-math.sqrt((Ka2**2)-(-4*1*Ka2*InitC2HO4)))/(2*1) \n",
      "     if(x1>0):#as only one root is positive\n",
      "          y=x1 \n",
      "     else: \n",
      "          y=x2 \n",
      "C2HO4=InitC2HO4-y #from first and second stages of ionisation\n",
      "H=x+y #from first and second stages of ionisation\n",
      "C2O4=y #from the assumption\n",
      "OH=Kw/H # From the formula (ionic product)Kw=[H+]*[OH-]\n",
      "\n",
      "#Result\n",
      "print\"The concentration of the [HC2O4-] ion in the solution is :\",round(C2HO4,3),\"M\"\n",
      "print\"The concentration of the [H+] ion in the solution is :\",round(H,3),\"M\" \n",
      "print\"The concentration of the [C2O4^2-] ion in the solution is :\",C2O4,\"M\"\n",
      "print\"The concentration of the [OH-] ion in the solution is :%.1e\"%OH,\"M\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The concentration of the [H2C2O4] in the solution is : 0.046 M\n",
        "The concentration of the [HC2O4-] ion in the solution is : 0.054 M\n",
        "The concentration of the [H+] ion in the solution is : 0.054 M\n",
        "The concentration of the [C2O4^2-] ion in the solution is : 6.1e-05 M\n",
        "The concentration of the [OH-] ion in the solution is :1.8e-13 M\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:15.13,Page no:690"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "InitCH3COONa=0.15 #Initial concentration of CH3COONa solution, M\n",
      "InitCH3COO=InitCH3COONa #concentration of [CH3COO-] ion after dissociation of CH3COONa solution, M\n",
      "#Let 'x' be the equilibrium concentration of the [OH-] and [CH3COOH] ions after hydrolysis of [CH3COO-], M\n",
      "Kb=5.6*10**-10 #equilibrium constant of hydrolysis, M\n",
      "import math\n",
      "\n",
      "#Calculation\n",
      "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)\n",
      "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\n",
      "if(approx>5):\n",
      "     x1=(-Kb+math.sqrt((Kb**2)-(-4*1*Kb*InitCH3COO)))/(2*1) \n",
      "     x2=(-Kb-math.sqrt((Kb**2)-(-4*1*Kb*InitCH3COO)))/(2*1) \n",
      "     if(x1>0):#as only one root is positive\n",
      "          x=x1 \n",
      "     else: \n",
      "          x=x2 \n",
      "pOH=-math.log10(x) #since x is the conc. of [OH-] ions\n",
      "pH=14-pOH \n",
      "\n",
      "#Result\n",
      "print\"The pH of the salt solution is :\",round(pH,2)\n",
      "percenthydrolysis=x/InitCH3COO*100 \n",
      "print\"The percentage of hydrolysis of the salt solution is :\",round(percenthydrolysis,4),\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The pH of the salt solution is : 8.96\n",
        "The percentage of hydrolysis of the salt solution is : 0.0061 %\n"
       ]
      }
     ],
     "prompt_number": 51
    }
   ],
   "metadata": {}
  }
 ]
}