{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "#5: Percentage" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.1, Page number 5.5" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.4 in terms of percentage is 40.0 %\n", "1.0 in terms of percentage is 100.0 %\n", "5/3 in terms of percentage is 166.67 %\n", "7x/y in terms of percentage is 700 x/y %\n", "1.23 in terms of percentage is 123.0 %\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=0.4;\n", "b=1.0;\n", "c=5/3;\n", "d=7;\n", "e=1.23;\n", "\n", "#Calculation\n", "A=a*100; #in terms of percentage(%)\n", "B=b*100; #in terms of percentage(%)\n", "C=c*100; #in terms of percentage(%)\n", "D=d*100; #in terms of percentage(%)\n", "E=e*100; #in terms of percentage(%)\n", "\n", "#Result\n", "print \"0.4 in terms of percentage is\",A,\"%\"\n", "print \"1.0 in terms of percentage is\",B,\"%\"\n", "print \"5/3 in terms of percentage is\",round(C,2),\"%\"\n", "print \"7x/y in terms of percentage is\",D,\"x/y %\"\n", "print \"1.23 in terms of percentage is\",E,\"%\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.2, Page number 5.5" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "22 1/2 in terms of fraction is 0.225\n", "35 in terms of fraction is 0.35\n", "a**2/b in terms of fraction is a**2/100b\n", "0.3 in terms of fraction is 0.003\n", "2/7 in terms of fraction is 0.0029\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=22+(1/2);\n", "b=35;\n", "c=0.3;\n", "d=2/7;\n", "\n", "#Calculation\n", "A=a/100; #in terms of fraction\n", "B=b/100; #in terms of fraction\n", "C=c/100; #in terms of fraction\n", "D=d/100; #in terms of fraction\n", "\n", "#Result\n", "print \"22 1/2 in terms of fraction is\",A\n", "print \"35 in terms of fraction is\",B\n", "print \"a**2/b in terms of fraction is a**2/100b\"\n", "print \"0.3 in terms of fraction is\",C\n", "print \"2/7 in terms of fraction is\",round(D,4)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.3, Page number 5.5" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "value in 1st case is 2.43\n", "value in 2nd case is 1.3\n", "value in 3rd case is 2.8\n", "value in 4th case is 80.0\n", "value in 5th case is 1.6\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "p1=9; \n", "a1=27;\n", "p2=0.02;\n", "a2=6500;\n", "p3=7/2;\n", "a3=80;\n", "p4=125;\n", "a4=64;\n", "p5=10;\n", "P5=5;\n", "a5=320;\n", "\n", "#Calculation\n", "A1=p1*a1/100;\n", "A2=p2*a2/100;\n", "A3=p3*a3/100;\n", "A4=p4*a4/100;\n", "A5=p5*P5*a5/(100*100);\n", "\n", "#Result\n", "print \"value in 1st case is\",A1\n", "print \"value in 2nd case is\",A2\n", "print \"value in 3rd case is\",A3\n", "print \"value in 4th case is\",A4\n", "print \"value in 5th case is\",A5" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.4, Page number 5.6" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "value in 1st case is 25.0 %\n", "value in 2nd case is 116.67 %\n", "value in 3rd case is 20.0 %\n", "value in 4th case is 50.0 %\n", "value in 5th case is 36.0 %\n", "value in 6th case is 100R/N %\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a1=36;\n", "b1=144;\n", "a2=7/8;\n", "b2=3/4;\n", "a3=16;\n", "b3=80;\n", "a4=0.625;\n", "b4=1+(7/28);\n", "a5=36*14;\n", "b5=1400;\n", "\n", "#Calculation\n", "v1=a1*100/b1; #value(%)\n", "v2=a2*100/b2; #value(%)\n", "v3=a3*100/b3; #value(%)\n", "v4=a4*100/b4; #value(%)\n", "v5=a5*100/b5; #value(%)\n", "\n", "#Result\n", "print \"value in 1st case is\",v1,\"%\"\n", "print \"value in 2nd case is\",round(v2,2),\"%\"\n", "print \"value in 3rd case is\",v3,\"%\"\n", "print \"value in 4th case is\",v4,\"%\"\n", "print \"value in 5th case is\",v5,\"%\"\n", "print \"value in 6th case is 100R/N %\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.5, Page number 5.7" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "value in 1st case is 600.0\n", "value in 2nd case is 50.0\n", "value in 3rd case is 240.0\n", "value in 4th case is 4.08\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "p1=6; \n", "a1=36;\n", "p2=5;\n", "a2=2.5;\n", "p3=25;\n", "P3=20;\n", "a3=12;\n", "p4=14;\n", "a4=4/7;\n", "\n", "#Calculation\n", "A1=a1*100/p1;\n", "A2=a2*100/p2;\n", "A3=a3*100*100/(p3*P3);\n", "A4=a4*100/p4;\n", "\n", "#Result\n", "print \"value in 1st case is\",A1\n", "print \"value in 2nd case is\",A2\n", "print \"value in 3rd case is\",A3\n", "print \"value in 4th case is\",round(A4,2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.6, Page number 5.7" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "40% of number is 32.0\n", "original number is 80.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "p1=25;\n", "p2=40;\n", "x1=20;\n", "\n", "#Calculation\n", "x2=x1*p2/p1; #40% of number \n", "N=x1*100/p1; #original number\n", "\n", "#Result\n", "print \"40% of number is\",x2\n", "print \"original number is\",N" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.8, Page number 5.8" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "B is short of A by 20.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "e=25; #% excess\n", "\n", "#Calculation\n", "s=e*100/(100+e); #%short\n", "\n", "#Result\n", "print \"B is short of A by\",s" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.9, Page number 5.8" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Y is excess of X by 66.67\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "s=40; #%short\n", "\n", "#Calculation\n", "e=s*100/(100-s); #% excess\n", "\n", "#Result\n", "print \"Y is excess of X by\",round(e,2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.10, Page number 5.8" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "salary of july more than that of june is 11.11 %\n", "salary of june less than that of july is 10.0 %\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "J=2+(1/2);\n", "j=2+(1/4);\n", "\n", "#Calculation\n", "d=J-j; #difference\n", "s1=d*100/j; #salary more(%)\n", "s2=d*100/J; #salary less(%)\n", "\n", "#Result\n", "print \"salary of july more than that of june is\",round(s1,2),\"%\"\n", "print \"salary of june less than that of july is\",s2,\"%\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.11, Page number 5.8" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "enrollment in 1988 is 1650.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "e=1500; #total enrollment\n", "p=10; #percentage increment\n", "\n", "#Calculation\n", "E=e*(100+p)/100; #enrollment in 1988\n", "\n", "#Result\n", "print \"enrollment in 1988 is\",E" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.13, Page number 5.9" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "area of rectangle decreases by 22.0 %\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "x=-40; #% decrease\n", "y=30; #% increase\n", "\n", "#Calculation\n", "n=x+y+((x*y)/100); #area of rectangle decreases by(%)\n", "\n", "#Result\n", "print \"area of rectangle decreases by\",-n,\"%\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.14, Page number 5.9" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "original daily wage is 20.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "i=23; #increased daily wage(%)\n", "pi=15; #percentage increase(%)\n", "\n", "#Calculation\n", "o=i*100/(100+pi); #original daily wage\n", "\n", "#Result\n", "print \"original daily wage is\",o" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.16, Page number 5.10" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Y gets 42.0 % above minimum\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "Y=710; #marks of Y\n", "X=515; #marks of X\n", "px=3; #% above\n", "\n", "#Calculation\n", "py=(Y*(100+px)/X)-100; #Y gets % above minimum\n", "\n", "#Result\n", "print \"Y gets\",py,\"% above minimum\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.18, Page number 5.10" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "% of scholarship holders is 22.0\n", "% of non scholarship holders is 78.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "b=3; #boys in ratio\n", "g=2; #girls in ratio\n", "pb=20; #% of boys\n", "pg=25; #% of girls\n", "\n", "#Calculation\n", "B=b/(b+g); #number of boys\n", "G=g/(b+g); #number of girls\n", "ps=(B*pb)+(G*pg); #% of scholarship holders\n", "pns=(B*(100-pb))+(G*(100-pg)); #% of non scholarship holders\n", "\n", "#Result\n", "print \"% of scholarship holders is\",ps\n", "print \"% of non scholarship holders is\",pns" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.19, Page number 5.10" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "% change in consumption is 11.11 %\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "Nr=27; #new rate(Rs)\n", "Or=24; #original rate(Rs)\n", "\n", "#Calculation\n", "pc=(Nr-Or)*100/Or; #% change in rate\n", "pcc=pc*100/(100+pc); #% change in consumption\n", "\n", "#Result\n", "print \"% change in consumption is\",round(pcc,2),\"%\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.20, Page number 5.11" ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "original price of sugar is Rs 4.0 per kg\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "e=16; #expenditure(Rs)\n", "rc=2; #rate change(Rs)\n", "qc=4; #change in quantity available(kg)\n", "\n", "#Calculation\n", "b=-rc; #coefficient of x\n", "a=1; #coefficient of x**2\n", "c=-e*rc/qc; #constant term\n", "x=(b**2)-(4*a*c);\n", "x1=(-b+math.sqrt(x))/(2*a); \n", "x2=(-b-math.sqrt(x))/(2*a); \n", "\n", "#Result\n", "print \"original price of sugar is Rs\",x1,\"per kg\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.21, Page number 5.11" ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "original price is Rs 8.0 per kg\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "e=120; #expenditure(Rs)\n", "rc=0.25; #rate change(Rs)\n", "qc=5; #change in quantity available(kg)\n", "\n", "#Calculation\n", "x=e*rc/(qc*(1-rc)); #original price(Rs/kg)\n", "\n", "#Result\n", "print \"original price is Rs\",x,\"per kg\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.22, Page number 5.11" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "% decrease in consumption is 2.913 %\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "cr=3; #change in rate(%)\n", "\n", "#Calculation\n", "dc=cr*100/(100+cr); #% decrease in consumption\n", "\n", "#Result\n", "print \"% decrease in consumption is\",round(dc,3),\"%\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.24, Page number 5.12" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "salary is 5000.0 Rs\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "p1=10; #deduction(%)\n", "p2=20; #deduction(%)\n", "p3=25; #deduction(%)\n", "l=2700; #left with amount(Rs)\n", "\n", "#Calculation\n", "x=(100-p1)*(100-p2)*(100-p3)/(100*100*100);\n", "s=l/x; #salary(Rs)\n", "\n", "#Result\n", "print \"salary is\",s,\"Rs\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.25, Page number 5.12" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "new consumption is 25.0 kg\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "p1=10; #% increase\n", "q=30; #quantity(kg)\n", "p2=32; #% increase\n", "\n", "#Calculation\n", "nc=(100+p1)*q/(100+p2); #new consumption(kg)\n", "\n", "#Result\n", "print \"new consumption is\",nc,\"kg\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.26, Page number 5.12" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "income after increase is Rs 7200.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=1200; #amount increased(Rs)\n", "p1=10; #% before\n", "p2=12; #% after\n", "\n", "#Calculation\n", "x=a*p2/(p2-p1); #income after increase(Rs)\n", "\n", "#Result\n", "print \"income after increase is Rs\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.27, Page number 5.12" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "value in 1st case is 280.0\n", "value in 2nd case is 0.5\n", "value in 3rd case is 225.0\n", "value in 4th case is 30.0\n", "value in 5th case is 880.0\n", "value in 6th case is 12.0\n", "value in 7th case is 0.4 %\n", "value in 8th case is 220.0\n", "value in 9th case is 150.0\n", "value in 10th case is 42.0\n", "value in 11th case is 0.75 %\n", "value in 12th case is 0.15\n", "value in 13th case is 0.375\n", "value in 14th case is 0.125\n", "value in 15th case is 15.0\n", "value in 16th case is 20.0\n", "value in 17th case is 300.0\n", "value in 18th case is 6.0\n", "answer given in the book is wrong\n", "value in 19th case is 1.05 x\n", "value in 20th case is 0.93 x\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a1=3/4;\n", "b1=48;\n", "c1=62;\n", "p1=35/100;\n", "p2=45/100;\n", "a2=5/6;\n", "P2=20/100;\n", "b2=4.375;\n", "a3=625;\n", "b3=1200;\n", "c3=320;\n", "p3=80/100;\n", "a4=3/5;\n", "b4=1450;\n", "p4=200/100;\n", "c4=450;\n", "a5=5+(1/2);\n", "b5=240;\n", "p5=150/100;\n", "a6=5/7;\n", "b6=49;\n", "c6=130;\n", "p6=20/100;\n", "a7=2*1000;\n", "b7=800;\n", "a8=534;\n", "b8=105;\n", "p8=(33+(1/3))/100;\n", "P8=40/100;\n", "p9=(26+(2/3))/100;\n", "a9=40;\n", "p10=(10+(1/2))/100;\n", "a10=400;\n", "a11=108;\n", "b11=81;\n", "a12=60;\n", "b12=72;\n", "p12=(12+(1/2))/100;\n", "p13=0.025/100;\n", "a13=1500;\n", "p14=25/100;\n", "P14=50/100;\n", "a15=150;\n", "a16=73;\n", "p17=11/100;\n", "a17=33;\n", "a18=350;\n", "b18=21;\n", "a19=5/100;\n", "a20=7/100;\n", "\n", "#Calculation\n", "v1=((a1*b1)+c1)/p1; #value in 1st case\n", "v2=(P2*b2)-(p2*a2); #value in 2nd case\n", "v3=((p3*b3)-c3-a3)**2; #value in 3rd case \n", "v4=(p4*c4)-(a4*b4); #value in 4th case \n", "v5=a5*b5/p5; #value in 5th case \n", "v6=(a6*b6)+(p6*c6)-b6; #value in 6th case \n", "v7=b7/a7; #value in 7th case \n", "v8=(p8*a8)+(P8*b8); #value in 8th case \n", "v9=a9/p9; #value in 9th case \n", "v10=p10*a10; #value in 10th case \n", "v11=b11/a11; #value in 11th case \n", "v12=b12*p12/a12; #value in 12th case \n", "v13=p13*a13; #value in 13th case\n", "v14=p14*P14; #value in 14th case\n", "v15=a15*100/1000; #value in 15th case\n", "v16=a16*100/365; #value in 16th case \n", "v17=a17/p17; #value in 17th case\n", "v18=b18*100/a18; #value in 18th case\n", "v19=1+a19; #value in 19th case \n", "v20=1-a20; #value in 20th case\n", "\n", "#Result\n", "print \"value in 1st case is\",v1\n", "print \"value in 2nd case is\",v2\n", "print \"value in 3rd case is\",v3\n", "print \"value in 4th case is\",v4\n", "print \"value in 5th case is\",v5\n", "print \"value in 6th case is\",v6\n", "print \"value in 7th case is\",v7,\"%\"\n", "print \"value in 8th case is\",v8\n", "print \"value in 9th case is\",v9\n", "print \"value in 10th case is\",v10\n", "print \"value in 11th case is\",v11,\"%\"\n", "print \"value in 12th case is\",v12\n", "print \"value in 13th case is\",v13\n", "print \"value in 14th case is\",v14\n", "print \"value in 15th case is\",v15\n", "print \"value in 16th case is\",v16\n", "print \"value in 17th case is\",v17\n", "print \"value in 18th case is\",v18\n", "print \"answer given in the book is wrong\"\n", "print \"value in 19th case is\",v19,\"x\"\n", "print \"value in 20th case is\",v20,\"x\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.28, Page number 5.15" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "saving increases by 25 %\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "si=10; #income(%)\n", "Si=25; #salary increase(%)\n", "\n", "#Calculation\n", "SI=Si; #saving increase(%)\n", "\n", "#Result\n", "print \"saving increases by\",SI,\"%\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.29, Page number 5.15" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "amount boy had is Rs 48.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "n=20; #number of books\n", "a1=25/100; #amount less(Rs)\n", "a2=70/100; #amount left(Rs)\n", "\n", "#Calculation\n", "X=((n+2)*a1)-a2;\n", "x=n*X/(n+2-n); #amount boy had(Rs) \n", "\n", "#Result\n", "print \"amount boy had is Rs\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.30, Page number 5.15" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "value of N is 20.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "p=80; #percentage(%)\n", "n=4; #reduced number\n", "\n", "#Calculation\n", "N=n*100/(100-p); #value of N\n", "\n", "#Result\n", "print \"value of N is\",N" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.31, Page number 5.15" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "value of N is 300.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "p=102; #percentage(%)\n", "n=6; #reduced number\n", "\n", "#Calculation\n", "N=n*100/(p-100); #value of N\n", "\n", "#Result\n", "print \"value of N is\",N" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.32, Page number 5.15" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "new value for 1st case is 320.0\n", "new value for 2nd case is 22.0\n", "new value for 3rd case is 105.0\n", "new value for 4th case is 54.0\n", "new value for 5th case is 1035.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a1=200;\n", "p1=60;\n", "a2=11;\n", "p2=100;\n", "a3=35;\n", "p3=200;\n", "a4=48;\n", "p4=12+(1/2);\n", "a5=1000;\n", "p5=3.5;\n", "\n", "#Calculation\n", "N1=a1*(100+p1)/100; #new value for 1st case\n", "N2=a2*(100+p2)/100; #new value for 2nd case\n", "N3=a3*(100+p3)/100; #new value for 3rd case\n", "N4=a4*(100+p4)/100; #new value for 4th case\n", "N5=a5*(100+p5)/100; #new value for 5th case\n", "\n", "#Result\n", "print \"new value for 1st case is\",N1\n", "print \"new value for 2nd case is\",N2\n", "print \"new value for 3rd case is\",N3\n", "print \"new value for 4th case is\",N4\n", "print \"new value for 5th case is\",N5" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.33, Page number 5.16" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "new value for 1st case is 120.0\n", "new value for 2nd case is 12.0\n", "new value for 3rd case is 135.0\n", "new value for 4th case is 292.5\n", "new value for 5th case is 998.0\n", "new value for 6th case is 43.75\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a1=200;\n", "p1=40;\n", "a2=16;\n", "p2=25;\n", "a3=216;\n", "p3=37+(1/2);\n", "a4=300;\n", "p4=2.5;\n", "a5=1000;\n", "p5=1/5;\n", "a6=50;\n", "p6=12+(1/2);\n", "\n", "#Calculation\n", "N1=a1*(100-p1)/100; #new value for 1st case\n", "N2=a2*(100-p2)/100; #new value for 2nd case\n", "N3=a3*(100-p3)/100; #new value for 3rd case\n", "N4=a4*(100-p4)/100; #new value for 4th case\n", "N5=a5*(100-p5)/100; #new value for 5th case\n", "N6=a6*(100-p6)/100; #new value for 6th case\n", "\n", "#Result\n", "print \"new value for 1st case is\",N1\n", "print \"new value for 2nd case is\",N2\n", "print \"new value for 3rd case is\",N3\n", "print \"new value for 4th case is\",N4\n", "print \"new value for 5th case is\",N5\n", "print \"new value for 6th case is\",N6" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.34, Page number 5.17" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "amount of bill is Rs 50.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "p=10; #percent(%)\n", "b=45; #decreased bill(Rs)\n", "\n", "#Calculation\n", "N=b*100/(100-p); #amount of bill(Rs)\n", "\n", "#Result\n", "print \"amount of bill is Rs\",N" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.35, Page number 5.17" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "number of milk chocolates/month is 7000.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "p=30; #percent(%)\n", "n=9100; #number of milk chocolates\n", "\n", "#Calculation\n", "N=n*100/(100+p); #number of milk chocolates\n", "\n", "#Result\n", "print \"number of milk chocolates/month is\",N" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.36, Page number 5.18" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "error is 2.0 %\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "fw=40.8; #false weight(kg)\n", "aw=40; #actual weight(kg)\n", "\n", "#Calculation\n", "e=(fw-aw)*100/aw; #error(%)\n", "\n", "#Result\n", "print \"error is\",e,\"%\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.37, Page number 5.18" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "new price per kg is Rs 50.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "d=10; #difference(Rs)\n", "dp=25; #difference in percent(%)\n", "\n", "#Calculation\n", "op=d*100/dp; #original price(Rs)\n", "np=op*(100+dp)/100; #new price per kg(Rs)\n", "\n", "#Result\n", "print \"new price per kg is Rs\",np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.38, Page number 5.18" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ratio of change in price to old price is 1/4\n", "ratio of old price to new price is 1.33\n", "factor is 3/4\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "from fractions import Fraction\n", "\n", "#Variable declaration\n", "cp=25; #change in price(Rs)\n", "op=100; #old price(Rs)\n", "\n", "#Calculation\n", "r1=cp/op; #ratio of change in price to old price\n", "r2=op/(op-cp); #ratio of old price to new price\n", "f=(100-cp)/100; #factor\n", "\n", "#Result\n", "print \"ratio of change in price to old price is\",Fraction(r1)\n", "print \"ratio of old price to new price is\",round(r2,2)\n", "print \"factor is\",Fraction(f)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.39, Page number 5.18" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "B=A* 0.91\n", "A=B* 11 /10\n", "A/B = 11 /10\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "p=10; #percent(%)\n", "\n", "#Calculation\n", "x2=(100+p)/100;\n", "x1=100/(100+p);\n", "\n", "#Result\n", "print \"B=A*\",round(x1,2)\n", "print \"A=B*\",int(x2*10),\"/10\"\n", "print \"A/B = \",int(x2*10),\"/10\"" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "##Example number 5.40, Page number 5.19" ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "X/Y = 0.8\n", "Y-X/Y = 0.2\n", "X/Y-X = 4\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "p=20; #percent(%)\n", "\n", "#Calculation\n", "x1=(100-p)/100;\n", "x2=p/100;\n", "x3=(100-p)/p;\n", "\n", "#Result\n", "print \"X/Y = \",x1\n", "print \"Y-X/Y = \",x2\n", "print \"X/Y-X = \",int(x3)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "##Example number 5.41, Page number 5.19" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "weight of table is 9.6 kg\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "p1=2+(1/2); #percent(%)\n", "w=0.2; #weight(kg)\n", "p2=120; #percent(%)\n", "\n", "#Calculation\n", "w=w*p2/p1; #weight of table(kg)\n", "\n", "#Result\n", "print \"weight of table is\",w,\"kg\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.42, Page number 5.20" ] }, { "cell_type": "code", "execution_count": 27, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "five times the sum of money is Rs 1740.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "p=1/8; #percent(%)\n", "a=43.50; #amount(Rs)\n", "\n", "#Calculation\n", "S=a*5/p; #five times the sum of money(Rs)\n", "\n", "#Result\n", "print \"five times the sum of money is Rs\",S" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.43, Page number 5.20" ] }, { "cell_type": "code", "execution_count": 29, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "q is less than p by 83.33 %\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "q=1;\n", "p=6*q; #number of times\n", "\n", "#Calculation\n", "x=(p-q)*100/p; #q is less than p by(%)\n", "\n", "#Result\n", "print \"q is less than p by\",round(x,2),\"%\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.44, Page number 5.20" ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "required percent is 0.25 %\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "n=0.05; #number\n", "p=20/100;\n", "\n", "#Calculation\n", "rp=n/p; #required percent(%)\n", "\n", "#Result\n", "print \"required percent is\",rp,\"%\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 5.45, Page number 5.20" ] }, { "cell_type": "code", "execution_count": 32, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "percent of sulphur in earth is 0.222 %\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "n1=5;\n", "n2=2250;\n", "\n", "#Calculation\n", "ps=n1*100/n2; #percent of sulphur in earth(%)\n", "\n", "#Result\n", "print \"percent of sulphur in earth is\",round(ps,3),\"%\"" ] } ], "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 }