{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 16: True Discount"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 16.1, Page number 16.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "present worth is 160.0 Rs\n",
      "true discount is 16.0 Rs\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "P=176;    #principal(Rs)\n",
    "R=6;       #rate(%)\n",
    "T=20/12;       #time(yrs)\n",
    "\n",
    "#Calculation\n",
    "PW=P/(1+(R*T/100));    #present worth(Rs)\n",
    "TD=P-PW;         #true discount(Rs)\n",
    "\n",
    "#Result\n",
    "print \"present worth is\",PW,\"Rs\"\n",
    "print \"true discount is\",TD,\"Rs\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 16.2, Page number 16.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "present worth is 2000.0 Rs\n",
      "true discount is 420.0 Rs\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "P=2420;    #principal(Rs)\n",
    "R=10;       #rate(%)\n",
    "T=2;       #time(yrs)\n",
    "\n",
    "#Calculation\n",
    "PW=P/((1+(R/100))**T);    #present worth(Rs)\n",
    "TD=P-PW;         #true discount(Rs)\n",
    "\n",
    "#Result\n",
    "print \"present worth is\",PW,\"Rs\"\n",
    "print \"true discount is\",TD,\"Rs\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 16.3, Page number 16.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "present worth is 3000.0 Rs\n",
      "amount of the bill is 3240.0 Rs\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "R=12;       #rate(%)\n",
    "T=8/12;       #time(yrs)\n",
    "TD=240;         #true discount(Rs)\n",
    "\n",
    "#Calculation\n",
    "PW=100*TD/(R*T);    #present worth(Rs)\n",
    "P=PW+TD;     #amount of the bill(Rs)\n",
    "\n",
    "#Result\n",
    "print \"present worth is\",PW,\"Rs\"\n",
    "print \"amount of the bill is\",P,\"Rs\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 16.4, Page number 16.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "difference between simple interest and true discount is 32.0 Rs\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "P=960;    #principal(Rs)\n",
    "R=5;       #rate(%)\n",
    "T=4;       #time(yrs)\n",
    "\n",
    "#Calculation\n",
    "SI_TD=(P*(R*T)**2)/(100*(100+(R*T)));       #difference between simple interest and true discount(Rs)\n",
    "\n",
    "#Result\n",
    "print \"difference between simple interest and true discount is\",SI_TD,\"Rs\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 16.5, Page number 16.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "principal is 38250.0 Rs\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "R=4;       #rate(%)\n",
    "T=6/12;       #time(yrs)\n",
    "SI_TD=15;     #difference between simple interest and true discount(Rs)\n",
    "\n",
    "#Calculation\n",
    "P=SI_TD*100*(100+(R*T))/((R*T)**2);       #principal(Rs)\n",
    "\n",
    "#Result\n",
    "print \"principal is\",P,\"Rs\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 16.6, Page number 16.6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "time is 4.0 months\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "P=2040;    #principal(Rs)\n",
    "R=6;       #rate(%)\n",
    "TD=40;     #true discount(Rs)\n",
    "\n",
    "#Calculation\n",
    "T=100*TD/(R*(P-TD));     #time(yrs)\n",
    "\n",
    "#Result\n",
    "print \"time is\",T*12,\"months\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 16.7, Page number 16.6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "rate is 1.11 %\n",
      "answer given in the book is wrong\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "P=1860;    #principal(Rs)\n",
    "T=3;       #time(yrs)\n",
    "TD=60;     #true discount(Rs)\n",
    "\n",
    "#Calculation\n",
    "R=100*TD/(T*(P-TD));    #rate(%)  \n",
    "\n",
    "#Result\n",
    "print \"rate is\",round(R,2),\"%\"\n",
    "print \"answer given in the book is wrong\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 16.8, Page number 16.6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "amount of the bill is 1575.0 Rs\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "T=5/12;       #time(yrs)\n",
    "TD=75;     #true discount(Rs)\n",
    "R=12;       #rate(%)\n",
    "\n",
    "#Calculation\n",
    "P=TD*(1+(100/(R*T)));    #amount of the bill(Rs)\n",
    "\n",
    "#Result\n",
    "print \"amount of the bill is\",P,\"Rs\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 16.9, Page number 16.6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "sum is 600.0 Rs\n",
      "rate per annum is 16.67 %\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "TD=200;     #true discount(Rs)\n",
    "SI=300;     #simple interest(Rs)\n",
    "T=3;       #time(yrs)\n",
    "\n",
    "#Calculation\n",
    "P=SI*TD/(SI-TD);      #sum(Rs)\n",
    "R=100*SI/(P*T);       #rate per annum(%)\n",
    "\n",
    "#Result\n",
    "print \"sum is\",P,\"Rs\"\n",
    "print \"rate per annum is\",round(R,2),\"%\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 16.10, Page number 16.7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "true discount is 96.0 Rs\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "TD1=60;     #true discount(Rs)\n",
    "T1=1;     #assume\n",
    "T2=2*T1;\n",
    "R1=R2=1;     #assume\n",
    "P=240;       #sum(Rs)\n",
    "\n",
    "#Calculation\n",
    "x=(P-TD1)/(T2*TD1);\n",
    "TD2=P/(x+1);      #true discount(Rs)\n",
    "\n",
    "#Result\n",
    "print \"true discount is\",TD2,\"Rs\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 16.11, Page number 16.7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "rate percent is 18.18 %\n",
      "sum of the bill is 1636.36 Rs\n",
      "answer varies due to rounding off errors\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "PW1=1500;    #present worth(Rs)\n",
    "PW2=1200;    #present worth(Rs)\n",
    "T1=6/12;       #time(yrs)\n",
    "T2=2;     #time(yrs)\n",
    "\n",
    "#Calculation\n",
    "x=PW1/PW2;\n",
    "R=100*(x-1)/(T2-(x*T1));     #rate percent(%)\n",
    "P=PW1*(1+(R*T1/100));       #sum of the bill(Rs)\n",
    "\n",
    "#Result\n",
    "print \"rate percent is\",round(R,2),\"%\"\n",
    "print \"sum of the bill is\",round(P,2),\"Rs\"\n",
    "print \"answer varies due to rounding off errors\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 16.12, Page number 16.7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "rate percent is 4.0 %\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "P1=600;       #sum(Rs)\n",
    "P2=720;       #sum(Rs)\n",
    "T=5;       #time(yrs)\n",
    "\n",
    "#Calculation\n",
    "R=((P2*T*100/(P1*T))-100)/T;      #rate percent(%)\n",
    "\n",
    "#Result\n",
    "print \"rate percent is\",R,\"%\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 16.13, Page number 16.8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "each installment should be 2000.0 Rs\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "P=8480;       #sum(Rs)\n",
    "n=4;    #number of installments\n",
    "r=16;    #rate percent(%)\n",
    "y=4;\n",
    "\n",
    "#Calculation\n",
    "x=r*n*(n-1)/(100*y*2);\n",
    "a=P/(x+n);    #each installment should be(Rs)\n",
    "\n",
    "#Result\n",
    "print \"each installment should be\",a,\"Rs\""
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}