diff options
Diffstat (limited to 'Quantitative_Aptitude_for_Competitive_Examinations/Chapter12.ipynb')
-rwxr-xr-x | Quantitative_Aptitude_for_Competitive_Examinations/Chapter12.ipynb | 760 |
1 files changed, 760 insertions, 0 deletions
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter12.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter12.ipynb new file mode 100755 index 00000000..def9a8d2 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter12.ipynb @@ -0,0 +1,760 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 12: Pipes and Cisterns"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.1, Page number 12.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken by leak to empty the cistern is 45.0 hours\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "f=4+(1/2); #time(hours)\n",
+ "x=1/2; #time(hours)\n",
+ "\n",
+ "#Calculation\n",
+ "E=f*(1+(f/x)); #time taken by leak to empty the cistern(hours)\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken by leak to empty the cistern is\",E,\"hours\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.2, Page number 12.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken by leak to empty the cistern is 112.0 hours\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x=32/60; #time(hours)\n",
+ "f1=14; #time for 1st pipe(hours)\n",
+ "f2=16; #time for 2nd pipe(hours)\n",
+ "\n",
+ "#Calculation\n",
+ "T=f1*f2/(f1+f2); #time(h)\n",
+ "E=T*(1+(T/x)); #time taken by leak to empty the cistern(hours)\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken by leak to empty the cistern is\",E,\"hours\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.3, Page number 12.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total time to fill is 12.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "f1=20; #time for 1st pipe(minutes)\n",
+ "f2=30; #time for 2nd pipe(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "T=f1*f2/(f1+f2); #total time to fill(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"total time to fill is\",T,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.4, Page number 12.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "fill or empty time is 50.0 minutes\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",
+ "f=25; #time(minutes)\n",
+ "e=50; #time(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "Et=1/((1/f)-(1/e)); #fill or empty time(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"fill or empty time is\",Et,\"minutes\"\n",
+ "print \"answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.5, Page number 12.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time to fill half the cistern is 8.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x1=3/4; #part of cistern\n",
+ "x2=1/2; #part of cistern\n",
+ "f1=12; #time to fill(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "f2=f1*x2/x1; #time to fill(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"time to fill half the cistern is\",f2,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.6, Page number 12.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ " part of cistern to be emptied is 3/8\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import Fraction\n",
+ "\n",
+ "#Variable declaration\n",
+ "e1=20; #time(minutes)\n",
+ "e2=9; #time(minutes)\n",
+ "y1=5/6; #part of cistern\n",
+ "\n",
+ "#Calculation\n",
+ "y2=e2*y1/e1; #part of cistern to be emptied\n",
+ "\n",
+ "#Result\n",
+ "print \"part of cistern to be emptied is\",Fraction(y2)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.7, Page number 12.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time to fill the cistern is 8.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a1=3; #time(minutes)\n",
+ "a2=15; #time(minutes)\n",
+ "b=10; #time(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "T=b*(1-(a1/a2)); #time to fill the cistern(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"time to fill the cistern is\",T,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.8, Page number 12.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time to fill the cistern is 9.143 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "At=12; #alone fill time of A(minutes)\n",
+ "Bt=16; #alone fill time of B(minutes)\n",
+ "t=4; #time(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "l=At*Bt/gcd(At,Bt); #lcm of At and Bt\n",
+ "a=l/At;\n",
+ "b=l/Bt;\n",
+ "T=(l+(t*a))/(a+b); #time to fill the cistern(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"time to fill the cistern is\",round(T,3),\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.9, Page number 12.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time to fill the cistern is 20.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "At=10; #time to fill cistern for A(minutes)\n",
+ "Bt=15; #time to fill cistern for B(minutes)\n",
+ "Ct=5; #time to empty cistern for C(minutes)\n",
+ "t=4; #time(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "l1=At*Bt/gcd(At,Bt); #lcm of At and Bt\n",
+ "l=l1*Ct/gcd(l1,Ct); #lcm of At,Ct and Bt\n",
+ "a=l/At;\n",
+ "b=l/Bt;\n",
+ "c=l/Ct;\n",
+ "T=(-(t*a)-(t*b))/(a+b-c); #time to empty the cistern(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"time to fill the cistern is\",T,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.10, Page number 12.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time to fill the cistern is 3.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "At=3; #time to fill cistern for A(minutes)\n",
+ "Bt=6; #time to fill cistern for B(minutes)\n",
+ "Ct=4; #time to empty cistern for B(minutes)\n",
+ "t=2; #time(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "x=1+(t/Ct);\n",
+ "l=At*Bt/gcd(At,Bt); #lcm of At and Bt\n",
+ "a=l/At;\n",
+ "b=l/Bt;\n",
+ "T=x*l/(a+b); #time to fill the cistern(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"time to fill the cistern is\",T,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.11, Page number 12.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total time to fill is 16.0 hours\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "f1=20; #time for 1st pipe(hours)\n",
+ "f2=30; #time for 2nd pipe(hours)\n",
+ "\n",
+ "#Calculation\n",
+ "F=f1*f2/(f1+f2); \n",
+ "T=F+(F/3); #total time to fill(hours)\n",
+ "\n",
+ "\n",
+ "#Result\n",
+ "print \"total time to fill is\",T,\"hours\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.12, Page number 12.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "capacity of cistern is 40.0 litres\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "f1=15; #time for 1st pipe(hours)\n",
+ "f2=10; #time for 2nd pipe(hours)\n",
+ "p=7; #capacity of carrying(litres/min)\n",
+ "E=2*60; #time(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "c=p/((1/f1)+(1/f2)+(1/E)); #capacity of cistern(litres)\n",
+ "\n",
+ "#Result\n",
+ "print \"capacity of cistern is\",c,\"litres\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.13, Page number 12.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time to fill the cistern is 3.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "ta=6; #fraction of time for A\n",
+ "t=21; #time to fill for B(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "F=t/(1+ta); #time to fill the cistern(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"time to fill the cistern is\",F,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.14, Page number 12.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time to fill the cistern is 8.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "K=4; #time(minutes)\n",
+ "L=30; #time(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "F=K*L/(K**2-1); #time to fill the cistern(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"time to fill the cistern is\",F,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.15, Page number 12.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total time to empty the cistern is 18.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "f1=10; #time for 1st pipe(minutes)\n",
+ "f2=15; #time for 2nd pipe(minutes)\n",
+ "tex=2; #extra time taken to fill(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "T=f1*f2/(f1+f2); #total time to fill(minutes)\n",
+ "E=T**2/tex; #total time to empty the cistern(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"total time to empty the cistern is\",E,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.16, Page number 12.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of filling pipes are 4.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "f=9; #fill rate(hours)\n",
+ "e=6; #empty rate(hours)\n",
+ "F=9; #total time(hours)\n",
+ "\n",
+ "#Calculation\n",
+ "a=(1/F)+1;\n",
+ "nf=a*f*e/(f+e); #number of filling pipes\n",
+ "\n",
+ "#Result\n",
+ "print \"number of filling pipes are\",nf"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.17, Page number 12.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "average sailing rate is 5.5 km/h\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "ra=2/6; #rate of admission of water(tonnes/min)\n",
+ "rp=12/60; #rate of pumping out water(tonnes/min)\n",
+ "q=80; #quantity of water(tonnes)\n",
+ "d=55; #distance(km)\n",
+ "\n",
+ "#Calculation\n",
+ "r=ra-rp; #rate of accumulation(tonnes/min)\n",
+ "T=q/(r*60); #time to accumulate water(hours)\n",
+ "Asr=d/T; #average sailing rate(km/h)\n",
+ "\n",
+ "#Result\n",
+ "print \"average sailing rate is\",Asr,\"km/h\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.18, Page number 12.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time before the full flow began is 4.5 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p1=7/8; #part1\n",
+ "p2=5/6; #part2\n",
+ "t1=12; #time(minutes)\n",
+ "t2=16; #time(minutes)\n",
+ "t=3; #time(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "a=(p1/t1)+(p2/t2);\n",
+ "b=1-(t/t1)-(t/t2);\n",
+ "x=b/a; #time before the full flow began(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"time before the full flow began is\",x,\"minutes\""
+ ]
+ }
+ ],
+ "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
+}
|