{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "#4: Simplification" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.1, Page number 4.7" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 1.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=10+(1/2);\n", "b=8+(1/2);\n", "c=6;\n", "d=7;\n", "e=6;\n", "f=4;\n", "\n", "#Calculation\n", "result=a-(b+(c-(d-(e-f))));\n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.2, Page number 4.8" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 1.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=0.75;\n", "b=0.25;\n", "\n", "#Calculation\n", "#given question is (a*a)+(b*b)+(2*a*b) which can be solved using (a+b)**2\n", "result=(a+b)**2;\n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.3, Page number 4.8" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 1.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=0.87;\n", "b=0.13;\n", "\n", "#Calculation\n", "Nr=(a**3)+(b**3);\n", "Dr=(a**2)+(b**2)-(a*b);\n", "result=Nr/Dr;\n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.4, Page number 4.8" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 576.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=9840;\n", "b=410;\n", "\n", "#Calculation\n", "result=(a/b)**2;\n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.5, Page number 4.8" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "required number is 70.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=40;\n", "b=30;\n", "c=10;\n", "\n", "#Calculation\n", "x=((a**2)-(b**2))/c; #required number\n", "\n", "#Result\n", "print \"required number is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.6, Page number 4.8" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "required number is 3\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=3;\n", "b=4;\n", "c=6;\n", "d=9;\n", "\n", "#Calculation\n", "p=b+c-d;\n", "x=a**p; #required number\n", "\n", "#Result\n", "print \"required number is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.7, Page number 4.8" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 2.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=2;\n", "b=math.sqrt(2);\n", "\n", "#Calculation\n", "c=1/(a+b);\n", "d=1/(b-a);\n", "result=a+b+c+d;\n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.8, Page number 4.9" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 243\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "x=7;\n", "y=5;\n", "z=2;\n", "\n", "#Calculation\n", "xstary=((x+z)**2)*(y-z);\n", "\n", "#Result\n", "print \"result is\",xstary " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.9, Page number 4.9" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 1000.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=121;\n", "\n", "#Calculation\n", "m=math.sqrt(a);\n", "#since we are considering square root, value of n will be 2\n", "n=2;\n", "result=(m-1)**(n+1); \n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.10, Page number 4.9" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 1.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "k=1;\n", "x=3*k;\n", "y=4*k;\n", "\n", "#Calculation\n", "result=(6/7)+((y-x)/(y+x));\n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.11, Page number 4.9" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 72.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "rootxminusrooty=1;\n", "rootxplusrooty=17;\n", "\n", "#Calculation\n", "#we get value of rootx and rooty by adding and subtracting the 2 equations\n", "rootx=(rootxminusrooty+rootxplusrooty)/2;\n", "rooty=(rootxplusrooty-rootxminusrooty)/2;\n", "result=rootx*rooty;\n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.12, Page number 4.9" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 17.28\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=12;\n", "b=0.2;\n", "c=3.6;\n", "d=2;\n", "\n", "#Calculation\n", "x=a*b*c*d;\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.13, Page number 4.9" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 3.11\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=7;\n", "b=18;\n", "c=84;\n", "\n", "#Calculation\n", "x=((c/b)**2)/7; \n", "\n", "#Result\n", "print \"result is\",round(x,2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.15, Page number 4.10" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 3.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=256;\n", "b=2;\n", "\n", "#Calculation\n", "c=math.log(a)/math.log(b);\n", "x=math.log(c)/math.log(b);\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.16, Page number 4.10" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 9.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=13;\n", "b=2;\n", "c=4;\n", "\n", "#Calculation\n", "d=math.log(c)/math.log(b);\n", "e=d*b;\n", "x=(a-e); \n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.17, Page number 4.10" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 6.0 *math.sqrt(3)\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=3*math.sqrt(27);\n", "b=math.sqrt(75);\n", "c=math.sqrt(12);\n", "\n", "#Calculation\n", "x=a-b+c; \n", "\n", "#Result\n", "print \"result is\",x/math.sqrt(3),\"*math.sqrt(3)\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.19, Page number 4.11" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 3 3/8\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "from fractions import Fraction\n", "\n", "#Variable declaration\n", "a=8+(1/4);\n", "b=8+(1/2);\n", "c=20+(1/8);\n", "\n", "#Calculation\n", "x=c-(a+b);\n", "y=x-int(x);\n", "\n", "#Result\n", "print \"result is\",int(x),Fraction(y)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.20, Page number 4.11" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 9.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=math.sqrt(1296);\n", "b=2.25;\n", "\n", "#Calculation\n", "c=a*b;\n", "x=math.sqrt(c);\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.21, Page number 4.11" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 95.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=124.9;\n", "b=63.15;\n", "c=65/100;\n", "\n", "#Calculation\n", "d=a-b;\n", "x=d/c;\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.22, Page number 4.11" ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 2.09090909091\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=17;\n", "aplusb=23;\n", "\n", "#Calculation\n", "b=aplusb-a;\n", "result=aplusb/(a-b);\n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.23, Page number 4.12" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 2.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=math.sqrt(24);\n", "b=math.sqrt(216);\n", "c=math.sqrt(96);\n", "\n", "#Calculation\n", "x=(a+b)/c;\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.25, Page number 4.12" ] }, { "cell_type": "code", "execution_count": 29, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 0.333333333333\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "x=5;\n", "y=-2;\n", "\n", "#Calculation\n", "result=(x-(2*y))**(1/y);\n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.26, Page number 4.12" ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 20.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=2+(2/3);\n", "b=4/5;\n", "c=1/6;\n", "\n", "#Calculation\n", "result=a/(b*c); \n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.27, Page number 4.12" ] }, { "cell_type": "code", "execution_count": 32, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "value of 5/6 of 1/20 of 24 rupees is 1.0 rupee\n", "value of 4/7 of 14 of 2 1/4 kg is 18.0 kg\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", "a=5/6;\n", "b=1/20;\n", "c=24;\n", "d=4/7;\n", "e=14;\n", "f=2+(1/4);\n", "\n", "#Calculation\n", "r1=a*b*c; #value of 5/6 of 1/20 of 24 rupees(rupee)\n", "r2=d*e*f; #value of 4/7 of 14 of 2 1/4 kg(kg)\n", "\n", "#Result\n", "print \"value of 5/6 of 1/20 of 24 rupees is\",r1,\"rupee\"\n", "print \"value of 4/7 of 14 of 2 1/4 kg is\",r2,\"kg\"\n", "print \"answer given in the book is wrong\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.28, Page number 4.12" ] }, { "cell_type": "code", "execution_count": 35, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 3.68181818182\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=11;\n", "b=2+(1/5);\n", "c=11/5;\n", "d=2+(1/2);\n", "e=2;\n", "\n", "#Calculation\n", "r1=a/b;\n", "r2=r1/c;\n", "result=(r2*d)-e;\n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.29, Page number 4.13" ] }, { "cell_type": "code", "execution_count": 36, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 1.27777777778\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=2/3;\n", "b=1/5;\n", "c=1/10;\n", "d=4/5;\n", "e=1/8;\n", "f=1/2;\n", "\n", "#Calculation\n", "Nr=a+b-c;\n", "Dr=(d*e)+f;\n", "result=Nr/Dr;\n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.30, Page number 4.13" ] }, { "cell_type": "code", "execution_count": 37, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 54.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=18;\n", "b=162;\n", "c=1;\n", "\n", "#Calculation\n", "x2=a*b*c;\n", "x=math.sqrt(x2);\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.31, Page number 4.13" ] }, { "cell_type": "code", "execution_count": 38, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 100.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=0.55;\n", "b=0.07;\n", "c=0.027;\n", "d=0.01;\n", "\n", "#Calculation\n", "Nr=(a**2)+(b**2)+(c**2);\n", "Dr=d*Nr;\n", "result=Nr/Dr;\n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.32, Page number 4.13" ] }, { "cell_type": "code", "execution_count": 39, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 270.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=137;\n", "b=133;\n", "\n", "#Calculation\n", "Nr=(a**3)+(b**3);\n", "Dr=(a**2)-(a*b)+(b**2);\n", "result=Nr/Dr;\n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.33, Page number 4.14" ] }, { "cell_type": "code", "execution_count": 40, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 2.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=20.25;\n", "b=2.8;\n", "c=28.35;\n", "\n", "#Calculation\n", "result=a*b/c;\n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.34, Page number 4.14" ] }, { "cell_type": "code", "execution_count": 41, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 0.0247933884298\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=54;\n", "b=66;\n", "c=33;\n", "\n", "#Calculation\n", "r=a/b;\n", "result=r/c;\n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.35, Page number 4.14" ] }, { "cell_type": "code", "execution_count": 43, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 229.0\n", "hence middle digit is 2\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=916;\n", "b=16;\n", "c=4;\n", "\n", "#Calculation\n", "r=a*c/b;\n", "\n", "#Result\n", "print \"result is\",r\n", "print \"hence middle digit is 2\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.36, Page number 4.14" ] }, { "cell_type": "code", "execution_count": 44, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 0.00121\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=0.011;\n", "b=10;\n", "\n", "#Calculation\n", "x=b*(a**2);\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.37, Page number 4.14" ] }, { "cell_type": "code", "execution_count": 45, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 1000.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=67.6;\n", "b=0.26;\n", "\n", "#Calculation\n", "x=a/(b**2); \n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.38, Page number 4.15" ] }, { "cell_type": "code", "execution_count": 46, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 0.18\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=0.324;\n", "b=10;\n", "\n", "#Calculation\n", "x=math.sqrt(a/b);\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.39, Page number 4.15" ] }, { "cell_type": "code", "execution_count": 47, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 2.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=63;\n", "b=36;\n", "\n", "#Calculation\n", "r1=(a+b)**2;\n", "r2=(a-b)**2;\n", "Nr=r1+r2;\n", "Dr=(a**2)+(b**2)\n", "x=Nr/Dr;\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.40, Page number 4.15" ] }, { "cell_type": "code", "execution_count": 48, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 111.5\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=44.6;\n", "b=2.5;\n", "\n", "#Calculation\n", "x=a*b;\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.41, Page number 4.15" ] }, { "cell_type": "code", "execution_count": 49, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 3.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=14;\n", "b=46;\n", "c=11;\n", "d=6;\n", "e=4;\n", "\n", "#Calculation\n", "Nr=(a**2)-b;\n", "Dr=(c*d)-(e**2);\n", "x=Nr/Dr;\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.42, Page number 4.15" ] }, { "cell_type": "code", "execution_count": 52, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 1803\n", "answer given in the book varies due to rounding off errors\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=2002;\n", "b=10.10;\n", "\n", "#Calculation\n", "x=a-(a/b);\n", "\n", "#Result\n", "print \"result is\",int(x)\n", "print \"answer given in the book varies due to rounding off errors\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.43, Page number 4.16" ] }, { "cell_type": "code", "execution_count": 56, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 0.333333333333\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=8;\n", "b=3;\n", "c=4;\n", "d=2;\n", "e=6;\n", "f=5;\n", "g=8;\n", "\n", "#Calculation\n", "Nr=a-(b*c)+d;\n", "Dr=-(e*f)+(b*g);\n", "x=Nr/Dr;\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.45, Page number 4.16" ] }, { "cell_type": "code", "execution_count": 61, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 4096 or 4 ** 6\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=4;\n", "b=3;\n", "c=2;\n", "d=5;\n", "e=0;\n", "\n", "#Calculation\n", "p=(a*b)-(b*c)+(d*e); #power is calculated using indices\n", "x=a**p;\n", "y=math.log(x)/math.log(a);\n", "\n", "#Result\n", "print \"result is\",x,\"or\",a,\"**\",int(y)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.46, Page number 4.16" ] }, { "cell_type": "code", "execution_count": 62, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 1.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=1;\n", "b=25/144;\n", "c=12;\n", "\n", "#Calculation\n", "r=math.sqrt(a+b);\n", "x=(r-a)*c;\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.47, Page number 4.16" ] }, { "cell_type": "code", "execution_count": 63, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 1.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "b=1;\n", "a=2;\n", "\n", "#Calculation\n", "x1=a-b;\n", "x2=a+b;\n", "result=(x1/x2)+(2/3);\n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.48, Page number 4.17" ] }, { "cell_type": "code", "execution_count": 64, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 28.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=18;\n", "b=14;\n", "c=84;\n", "\n", "#Calculation\n", "x=(c**2)/(a*b);\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.49, Page number 4.17" ] }, { "cell_type": "code", "execution_count": 65, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 9.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=243;\n", "b=0.8;\n", "c=0.4;\n", "\n", "#Calculation\n", "p=b-c;\n", "x=a**p;\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.50, Page number 4.17" ] }, { "cell_type": "code", "execution_count": 66, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 4.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=1.2;\n", "b=0.8;\n", "\n", "#Calculation\n", "x=(a**2)+(b**2)+(2*a*b);\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.51, Page number 4.17" ] }, { "cell_type": "code", "execution_count": 67, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 0.352272727273\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=64/121;\n", "b=9/64;\n", "c=8/11;\n", "d=3/8;\n", "\n", "#Calculation\n", "x=(a-b)/(c+d);\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.52, Page number 4.17" ] }, { "cell_type": "code", "execution_count": 68, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 1.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=0.1;\n", "b=0.75;\n", "c=2.5;\n", "d=0.05;\n", "e=0.125;\n", "f=1/4.8;\n", "\n", "#Calculation\n", "r1=(a+b)/(c+d);\n", "x=r1/(e+f);\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.53, Page number 4.18" ] }, { "cell_type": "code", "execution_count": 70, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 8731552810114645/18014398509481984\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=1/246;\n", "b=2/3;\n", "c=1/27;\n", "d=4/3;\n", "\n", "#Calculation\n", "r1=a**(-b);\n", "r2=c**(-d);\n", "x=r1/r2;\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.54, Page number 4.18" ] }, { "cell_type": "code", "execution_count": 71, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 800.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=8;\n", "b=5/3;\n", "c=125;\n", "d=2/3;\n", "\n", "#Calculation\n", "r1=a**b;\n", "r2=c**(-d);\n", "x=r1/r2;\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.55, Page number 4.18" ] }, { "cell_type": "code", "execution_count": 74, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 1.33333333333\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=6;\n", "b=-2;\n", "c=81;\n", "d=-3/4;\n", "\n", "#Calculation\n", "r1=1/(a**b);\n", "r2=c**d;\n", "x=r1*r2;\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.56, Page number 4.18" ] }, { "cell_type": "code", "execution_count": 75, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 10.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=math.sqrt(147);\n", "b=math.sqrt(27);\n", "c=math.sqrt(3);\n", "\n", "#Calculation\n", "x=(a+b)/c;\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.57, Page number 4.19" ] }, { "cell_type": "code", "execution_count": 77, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 2.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=math.sqrt(98);\n", "b=math.sqrt(50);\n", "c=math.sqrt(2);\n", "\n", "#Calculation\n", "x=(a-b)/c;\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.58, Page number 4.19" ] }, { "cell_type": "code", "execution_count": 78, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 2.35\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=math.sqrt(9/25);\n", "b=3+(1/16);\n", "c=math.sqrt(b);\n", "\n", "#Calculation\n", "x=a+c;\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.59, Page number 4.19" ] }, { "cell_type": "code", "execution_count": 80, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 0.18\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", "a=math.sqrt(0.01);\n", "b=math.sqrt(0.0064);\n", "\n", "#Calculation\n", "x=a+b;\n", "\n", "#Result\n", "print \"result is\",x\n", "print \"answer given in the book is wrong\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.60, Page number 4.19" ] }, { "cell_type": "code", "execution_count": 81, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 0.688995215311\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=25.6;\n", "b=36.1;\n", "c=12.1;\n", "d=81;\n", "e=0.1;\n", "\n", "#Calculation\n", "r1=math.sqrt(a/b);\n", "r2=math.sqrt(c/(d*e));\n", "x=r1/r2;\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.61, Page number 4.19" ] }, { "cell_type": "code", "execution_count": 83, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "51 can be expressed as 26 **2 - 25 **2\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "N=51;\n", "\n", "#Calculation\n", "#to express a number as the difference of squares of 2 numbers, we use the formula N=((N+1)/2)**2-((N-1)/2)**2\n", "a=(N+1)/2;\n", "b=(N-1)/2;\n", "#N can be expressed as (a**2)-(b**2)\n", "\n", "#Result\n", "print \"51 can be expressed as\",int(a),\"**2 - \",int(b),\"**2\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.62, Page number 4.19" ] }, { "cell_type": "code", "execution_count": 84, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 308.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=7;\n", "b=11;\n", "c=1232;\n", "\n", "#Calculation\n", "x2=a*b*c;\n", "x=math.sqrt(x2);\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.63, Page number 4.20" ] }, { "cell_type": "code", "execution_count": 85, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 5.41666666667\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=3+(1/4);\n", "b=4+(1/3);\n", "\n", "#Calculation\n", "Nr=(a**4)-(b**4);\n", "Dr=(a**2)-(b**2);\n", "result=math.sqrt(Nr/Dr);\n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.64, Page number 4.20" ] }, { "cell_type": "code", "execution_count": 86, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "total score in innings is 162.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=2/9;\n", "b=8;\n", "\n", "#Calculation\n", "x=b/(a**2); #total score in innings\n", "\n", "#Result\n", "print \"total score in innings is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.65, Page number 4.20" ] }, { "cell_type": "code", "execution_count": 90, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 17.125\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=64;\n", "b=32;\n", "c=-1/2;\n", "d=4/5;\n", "\n", "#Calculation\n", "r1=(1/a)**0;\n", "r2=a**c;\n", "r3=b**d;\n", "result=r1+r2+r3;\n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.66, Page number 4.21" ] }, { "cell_type": "code", "execution_count": 91, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 3.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=243;\n", "b=0.12;\n", "c=0.08;\n", "\n", "#Calculation\n", "p=b+c;\n", "result=a**p;\n", "\n", "#Result\n", "print \"result is\",result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.67, Page number 4.21" ] }, { "cell_type": "code", "execution_count": 92, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 12.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=2;\n", "b=64;\n", "\n", "#Calculation\n", "c=math.log(b)/math.log(a);\n", "n=c*a;\n", "\n", "#Result\n", "print \"result is\",n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.68, Page number 4.21" ] }, { "cell_type": "code", "execution_count": 96, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 36.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=1/216;\n", "b=2/3;\n", "\n", "#Calculation\n", "x=1/(a**b);\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.69, Page number 4.21" ] }, { "cell_type": "code", "execution_count": 97, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 16.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=-2;\n", "\n", "#Calculation\n", "b=a**a;\n", "x=b**a;\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.70, Page number 4.21" ] }, { "cell_type": "code", "execution_count": 98, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 2.4\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=11+(1/3);\n", "b=4+(8/10);\n", "c=22+(2/3);\n", "\n", "#Calculation\n", "x=a*b/c;\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.71, Page number 4.22" ] }, { "cell_type": "code", "execution_count": 99, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 1.0404\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "a=1.06;\n", "b=0.04;\n", "c=4;\n", "\n", "#Calculation\n", "r1=(a+b)**2;\n", "x=r1-(4*a*b);\n", "\n", "#Result\n", "print \"result is\",x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.72, Page number 4.22" ] }, { "cell_type": "code", "execution_count": 102, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is +/- 1/2\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "from fractions import Fraction\n", "\n", "#Variable declaration\n", "a2plusb2=45;\n", "ab=18;\n", "\n", "#Calculation\n", "Nr=math.sqrt(a2plusb2+(2*ab));\n", "result=Nr/ab;\n", "\n", "#Result\n", "print \"result is +/-\",Fraction(result)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Example number 4.75, Page number 4.23" ] }, { "cell_type": "code", "execution_count": 103, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "result is 4\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "#by comparing the equations we get\n", "rootx=2;\n", "\n", "#Calculation\n", "x=rootx**2;\n", "\n", "#Result\n", "print \"result is\",x" ] } ], "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 }