{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 19:Electrochemistry"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:19.3,Page no:848"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "E0cathode=0.8 #standard electrode potential of cathode(Ag+/Ag), V\n",
      "E0anode=-2.37 #standard electrode potential of anode(Mg2+/Mg), V\n",
      "\n",
      "#Calculation\n",
      "E0cell=E0cathode-E0anode #standard emf of the cell, V\n",
      "\n",
      "#Result\n",
      "print\"The standard emf of the cell is :\",E0cell,\"V\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The standard emf of the cell is : 3.17 V\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:19.4,Page no:850"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "n=2.0 \n",
      "E0cathode=0.15 #standard electrode potential of cathode(Cu2+/Cu+), V\n",
      "E0anode=-0.14 #standard electrode potential of anode(Sn2+/Sn), V\n",
      "\n",
      "#Calculation\n",
      "E0cell=E0cathode-E0anode #standard emf of the cell, V\n",
      "import math\n",
      "K=math.exp(round(n*E0cell/0.0257,1)) #equilibrium constant, from the formula E0cell=0.0257*lnK/n\n",
      "\n",
      "#Result\n",
      "print\"The equilibrium constant for the given reaction is :%.e\"%K "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "0.29\n",
        "The equilibrium constant for the given reaction is :7e+09\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:19.5,Page no:851"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "n=6 \n",
      "F=96500 #faraday constant, J/V mol\n",
      "E0cathode=-2.87 #standard electrode potential of cathode(Ca2+/Ca), V\n",
      "E0anode=1.5 #standard electrode potential of anode(Au3+/Au), V\n",
      "\n",
      "#Calculation\n",
      "E0cell=E0cathode-E0anode #standard emf of the cell, V\n",
      "deltaG0=-n*F*E0cell #standard free energy change for the reaction, kJ/mol\n",
      "\n",
      "#Result\n",
      "print\"The standard free energy change for the reaction is :%.2e\"%(deltaG0/1000),\"kJ/mol\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The standard free energy change for the reaction is :2.53e+03 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:19.6,Page no:853"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "n=2 \n",
      "F=96500 #faraday constant, J/V mol\n",
      "Co2=0.15 #conc of Co2+ ions, M\n",
      "Fe2=0.68 #conc of Fe2+ ions, M\n",
      "E0cathode=-0.44 #standard electrode potential of cathode(Fe2+/Fe), V\n",
      "E0anode=-0.28 #standard electrode potential of anode(Co2+/Co), V\n",
      "\n",
      "#Calculation\n",
      "import math\n",
      "E0cell=E0cathode-E0anode #standard emf of the cell, V\n",
      "Ecell=E0cell-0.0257/2*math.log(Co2/Fe2) #calculation of cell potential at non standard conditions, V\n",
      "\n",
      "#Result\n",
      "print \"E=\",round(Ecell,2),\"V\"\n",
      "if(Ecell>0):\n",
      "    print\"The reaction would proceed spontaneously in the direction written\"\n",
      "else:\n",
      "    print\"The reaction is not spontaneously in the direction written\"\n",
      "    "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "E= -0.14 V\n",
        "The reaction is not spontaneously in the direction written\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:19.7,Page no:855"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "n=2 \n",
      "Zn=1 #conc of Zn2+ ions, M\n",
      "pH2=1 #pressure of H2 gas, atm\n",
      "Ecell=0.54 #emf of the cell, V\n",
      "E0cell=0.76 #standard emf of the cell, V\n",
      "\n",
      "#Calculation\n",
      "import math\n",
      "Q=math.exp(-(Ecell-E0cell)*2/0.0257) #since Ecell=E0cell-0.0257/2*log(Q) where Q=(Zn2+)*pH2/(H+)**2\n",
      "H=math.sqrt(Zn*pH2/Q) #the conc of H+ ions, M\n",
      "\n",
      "#Result\n",
      "print\"The molar concentration of H+ ion is :%.e\"%H,\"M\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The molar concentration of H+ ion is :2e-04 M\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:19.9,Page no:870"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "t=7.44*3600 #time, sec\n",
      "A=1.26 #current in ampere\n",
      "F=96500.0 #faraday constant, J/V mol\n",
      "R=0.0821 #gas constant, L atm/K\n",
      "T=273.0 #temperature in Kelvin\n",
      "P=1.0 #pressure in atm\n",
      "\n",
      "#Calculation\n",
      "q=A*t #charge passed, coulomb\n",
      "ne=q/F #moles of electrons\n",
      "nO2=ne/4.0 #moles of oxygen\n",
      "nH2=ne/2.0 #moles of H2\n",
      "VO2=nO2*R*T/P #volume of oxygen gas generated\n",
      "VH2=nH2*R*T/P #volume of H2 gas generated\n",
      "\n",
      "#Result\n",
      "print\"The volume of O2 gas is:\",round(VO2,2),\"L\"\n",
      "print\"Volume of H2 gas generated is:\",round(VH2,2),\"L\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The volume of O2 gas is: 1.96 L\n",
        "Volume of H2 gas generated is: 3.92 L\n"
       ]
      }
     ],
     "prompt_number": 26
    }
   ],
   "metadata": {}
  }
 ]
}