{
 "metadata": {
  "name": "EE-9"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": "Depreciation"
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": "Example 9.1 Page 127"
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "#initiation of variable\nP=100000.0;#in Rs\nF=20000.0;#in Rs\nn=8.0;#in years\neoy=[0,1,2,3,4,5,6,7,8]#end of year\nBt=100000;#book vakue\n\n#calcualtion\nDt=(P-F)/n;#in Rs.\n\n#result\nprint \"End of year          Depreciation          Book value\";\nfor i in range (8):\n    B=Bt-i*Dt;\n    print  eoy[i],\"                    \",Dt,\"            \", B,\" \";\n     \n    \n    ",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "End of year          Depreciation          Book value\n0                      10000.0              100000.0  \n1                      10000.0              90000.0  \n2                      10000.0              80000.0  \n3                      10000.0              70000.0  \n4                      10000.0              60000.0  \n5                      10000.0              50000.0  \n6                      10000.0              40000.0  \n7                      10000.0              30000.0  \n"
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": "Example 9.2 Page 127"
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "#initiation of variable\nP=100000.0;#in Rs\nF=20000.0;#in Rs\nn=8.0;#in years\n\n#calculation\nD5=(P-F)/n;#in Rs.\nt=5;#in years\nBt=P-t*(P-F)/n;#in Rs\n\n#result\nprint \"D5 in Rs. : \",round(D5,3);\nprint \"(This is independent of the time period)\";\nprint \"B5 in Rs. : \",round(Bt,3);",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "D5 in Rs. :  10000.0\n(This is independent of the time period)\nB5 in Rs. :  50000.0\n"
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": "Example 9.3 Page 129"
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "#initiation of variable\nP=100000.0;#in Rs\nF=20000.0;#in Rs\nn=8.0;#in years\nk=0.2\neoy=[0,1,2,3,4,5,6,7,8]#end of year\nBt=[100000.0,0,0,0,0,0,0,0,0];#book vakue\nDt=[0.0,0,0,0,0,0,0,0,0];\n\n#result\nprint \"End of year          Depreciation          Book value\";\nprint \"0                      0                    100000\"\nfor i in xrange (1,9):\n    Dt[i]=k*Bt[i-1];\n    Bt[i]=Bt[i-1]-Dt[i];\n    print  eoy[i],\"                    \",Dt[i],\"            \", Bt[i],\" \";",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "End of year          Depreciation          Book value\n0                      0                    100000\n1                      20000.0              80000.0  \n2                      16000.0              64000.0  \n3                      12800.0              51200.0  \n4                      10240.0              40960.0  \n5                      8192.0              32768.0  \n6                      6553.6              26214.4  \n7                      5242.88              20971.52  \n8                      4194.304              16777.216  \n"
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": "Example 9.4 Page 128"
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "#initiation of variable\nP=100000.0;#in Rs\nF=20000.0;#in Rs\nn=8.0;#in years\nk=0.2\nt=5.0;#in years\n\n#calculation\nDt=k*(1-k)**(t-1)*P;#in Rs.\nBt=((1-k)**t)*P;#in Rs.\n\n#result\nprint \"D5 in Rs. : \",round(Dt,3);\nprint \"B5 in Rs. : \",round(Bt,3);",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "D5 in Rs. :  8192.0\nB5 in Rs. :  32768.0\n"
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": "Example 9.5 Page 129"
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "#initiation of variable\nP=100000.0;#in Rs\nF=20000.0;#in Rs\nn=8.0;#in years\nSum=n*(n+1)/2;#sum of the years\neoy=[0,1,2,3,4,5,6,7,8]#end of year\nBt=[100000.0,0,0,0,0,0,0,0,0];#book vakue\nDt=[0.0,0,0,0,0,0,0,0,0];\nrate=[0.0,0,0,0,0,0,0,0,0];\n\n#result\nprint \"End of year          Depreciation          Book value\";\nprint \"0                      0                    100000\"\nfor i in xrange (1,9):\n    rate[i]=(8-i+1)/36.0;\n    Dt[i]=rate[i]*(P-F);\n    Bt[i]=Bt[i-1]-Dt[i];\n    print  eoy[i],\"                    \",Dt[i],\"            \", Bt[i],\" \";",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "End of year          Depreciation          Book value\n0                      0                    100000\n1                      17777.7777778              82222.2222222  \n2                      15555.5555556              66666.6666667  \n3                      13333.3333333              53333.3333333  \n4                      11111.1111111              42222.2222222  \n5                      8888.88888889              33333.3333333  \n6                      6666.66666667              26666.6666667  \n7                      4444.44444444              22222.2222222  \n8                      2222.22222222              20000.0  \n"
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": "Example 9.6 Page 131"
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "#initiation of variable\nP=100000.0;#in Rs\nF=20000.0;#in Rs\nn=8.0;#in years\nt=5.0;#in years\n\n#cacualtion\nDt=(n-t+1)*(P-F)/(n*(n+1)/2);#in Rs.\nBt=(P-F)*((n-t)/n)*((n-t+1)/(n+1))+F;#in Rs.\n\n#result\nprint \"D5 in Rs. : \",round(Dt,3);\nprint \"B5 in Rs. : \",round(Bt,3);",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "D5 in Rs. :  8888.889\nB5 in Rs. :  33333.333\n"
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": "Example 9.7 Page 132"
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "#initiation of variable\nP=100000.0;#in Rs\nF=20000.0;#in Rs\nn=8.0;#in years\nk=0.12;\ni=12.0;#in % per annum\neoy=[0,1,2,3,4,5,6,7,8]#end of year\nBt=[100000.0,0,0,0,0,0,0,0,0];#book vakue\nDt=[0.0,0,0,0,0,0,0,0,0];\nrate=[0.0,0,0,0,0,0,0,0,0];\nSUM=0;\n\n#calculation\nA=(P-F)*(i/100)/(((1+i/100)**n)-1);\n\n#result\nprint \"End of year          Net Depreciation          Book value\";\nprint \"0                      0                         100000\"\nfor i in xrange (1,9):\n    Dt[i]=k*SUM+A;\n    SUM=SUM+Dt[i]\n    Bt[i]=Bt[i-1]-Dt[i];\n    print  eoy[i],\"                    \",round(Dt[i],3),\"            \", round(Bt[i],3),\" \";\n    \nprint \"fixed deprececiation which is constant in Rs\",round(A,3);",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "End of year          Net Depreciation          Book value\n0                      0                         100000\n1                      6504.227              93495.773  \n2                      7284.735              86211.038  \n3                      8158.903              78052.135  \n4                      9137.971              68914.164  \n5                      10234.528              58679.637  \n6                      11462.671              47216.966  \n7                      12838.191              34378.774  \n8                      14378.774              20000.0  \nfixed deprececiation which is constant in Rs 6504.227\n"
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": "Example 9.8 Page 133"
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "#initiation of variable\nP=100000.0;#in Rs\nF=20000.0;#in Rs\nn=8.0;#in years\ni=12.0;#in % per annum\nt=5.0;#in Years\n\n#calculation\nDt=(P-F)*(i/100)/(((1+i/100)**n)-1)*(1+i/100)**(t-1);#in Rs.\nt=7;#in Years\nBt=P-(P-F)*(i/100)/(((1+i/100)**n)-1)*(((1+i/100)**t)-1)/(i/100);#in Rs.\n\n#result\nprint \"D7 in Rs. : \",round(Dt,3);\nprint \"B7 in Rs. : \",round(Bt,3);",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "D7 in Rs. :  10234.528\nB7 in Rs. :  34378.774\n"
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": "Example 9.9 Page 134"
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "#initiation of variable\nP=8000000.0;#in Rs\nF=50000.0;#in Rs\nX=75000.0;#in Km\nx=2000.0;#in Km\nn=8.0;#in years\ni=12.0;#in % per annum\n\n#calcualtion\nD=(P-F)*x/X;#in Rs.\n\n#result\nprint \"Depreciation for year 3 in Rs. : \",round(D,3);",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "Depreciation for year 3 in Rs. :  212000.0\n"
      }
     ],
     "prompt_number": 32
    }
   ],
   "metadata": {}
  }
 ]
}