diff options
Diffstat (limited to 'Quantitative_Aptitude_for_Competitive_Examinations/Chapter11.ipynb')
-rwxr-xr-x | Quantitative_Aptitude_for_Competitive_Examinations/Chapter11.ipynb | 765 |
1 files changed, 765 insertions, 0 deletions
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter11.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter11.ipynb new file mode 100755 index 00000000..c9ef92fc --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter11.ipynb @@ -0,0 +1,765 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 11: Time and Work"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.1, Page number 11.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "A and B can do the job together in 12.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "t1=20; #number of days A can do a job\n",
+ "t2=30; #number of days B can do a job\n",
+ "\n",
+ "#Calculation\n",
+ "T=t1*t2/(t1+t2); #number of days for A and B to do the job together\n",
+ "\n",
+ "#Result\n",
+ "print \"A and B can do the job together in\",T,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.2, Page number 11.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "A can do the job in 21.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "t1=28; #number of days B can do a job\n",
+ "T=12; #number of days for A and B to do the job together\n",
+ "\n",
+ "#Calculation\n",
+ "t2=T*t1/(t1-T); #number of days A can do a job\n",
+ "\n",
+ "#Result\n",
+ "print \"A can do the job in\",t2,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.3, Page number 11.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "work done by A, B and C together is 10.0 days\n",
+ "work done by A alone is 30.0 days\n",
+ "work done by B alone is 20.0 days\n",
+ "work done by C alone is 60.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "T1=12; #work done by A and B together(days)\n",
+ "T2=15; #work done by C and B together(days)\n",
+ "T3=20; #work done by A and C together(days)\n",
+ "\n",
+ "#Calculation\n",
+ "l1=T1*T2/gcd(T1,T2); #lcm of T1 and T2\n",
+ "L=l1*T3/gcd(l1,T3); #lcm of the given 3 numbers\n",
+ "a=L/T1;\n",
+ "b=L/T2;\n",
+ "c=L/T3;\n",
+ "T=2*L/(a+b+c); #work done by A, B and C together(days)\n",
+ "Ta=2*L/(a-b+c); #work done by A alone(days)\n",
+ "Tb=2*L/(a+b-c); #work done by B alone(days)\n",
+ "Tc=2*L/(-a+b+c); #work done by C alone(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"work done by A, B and C together is\",T,\"days\"\n",
+ "print \"work done by A alone is\",Ta,\"days\"\n",
+ "print \"work done by B alone is\",Tb,\"days\"\n",
+ "print \"work done by C alone is\",Tc,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.4, Page number 11.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total work is finished in 8.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "Ta=10; #alone time of A(days)\n",
+ "TB=3; #number of days B worked(days)\n",
+ "Tb=15; #alone time of B(days)\n",
+ "\n",
+ "#Calculation\n",
+ "T=Ta*(1-(TB/Tb)); #total work finished(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"total work is finished in\",T,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.5, Page number 11.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total work is finished in 15.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "Ta=20; #alone time of A(days)\n",
+ "Tb=30; #alone time of B(days)\n",
+ "a=5; #number of days A leaves(days)\n",
+ "\n",
+ "#Calculation\n",
+ "L=Ta*Tb/gcd(Ta,Tb); #lcm of T1 and T2\n",
+ "l1=L/Ta;\n",
+ "l2=L/Tb;\n",
+ "T=(L+(l1*a))/(l1+l2); #total work finished(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"total work is finished in\",T,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.6, Page number 11.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total work is finished in 8.72727272727 days\n",
+ "B worked for 2.72727272727 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "Ta=10; #alone time of A(days)\n",
+ "Tb=12; #alone time of B(days)\n",
+ "a=6; #number of days after A started(days)\n",
+ "\n",
+ "#Calculation\n",
+ "L=T1*T2/gcd(T1,T2); #lcm of T1 and T2\n",
+ "l1=L/Ta;\n",
+ "l2=L/Tb;\n",
+ "T=(L+(l1*a))/(l1+l2); #total work finished(days)\n",
+ "TB=T-a; #number of days B worked for(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"total work is finished in\",T,\"days\"\n",
+ "print \"B worked for\",TB,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.7, Page number 11.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of days to complete the job is 10.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "M1=1; #number of men\n",
+ "E1=1; #efficiency of anil\n",
+ "D1=8; #number of days worked(days)\n",
+ "E=60/100; #efficiency of rakesh(%)\n",
+ "P1=1/3; #part of work done by anil\n",
+ "M2=1; #number of men\n",
+ "\n",
+ "#Calculation\n",
+ "E2=(M1*M2)+(E1*E); #efficiency\n",
+ "P2=1-P1; #part of work done by rakesh\n",
+ "D2=M1*E1*D1*P2/(P1*E2); #number of days to complete the job(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"number of days to complete the job is\",D2,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.8, Page number 11.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken for A to complete the job is 6 1/4 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import Fraction\n",
+ "\n",
+ "#Variable declaration\n",
+ "T1=5; #work done by A and B together(days)\n",
+ "T=1; #total job done\n",
+ "eB=1/3; #efficiency of B\n",
+ "\n",
+ "#Calculation\n",
+ "t=T-(T/T1); \n",
+ "tA=T1*(1/t); #time taken for A to complete the job(days)\n",
+ "x=tA-int(tA);\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken for A to complete the job is\",int(tA),Fraction(x),\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.9, Page number 11.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "A can finish in 2.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "M1=1; #number of men\n",
+ "D1=12; #number of days worked(days)\n",
+ "M2=1; #number of men\n",
+ "W1=3/4; #work done by A\n",
+ "W2=1/8; #part of work done\n",
+ "\n",
+ "#Calculation\n",
+ "d=M1*D1*W2/(W1*M2); #number of days for A(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"A can finish in\",d,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.10, Page number 11.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total work is finished in 7.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "Ta=10; #alone time of A(days)\n",
+ "Tb=12; #alone time of B(days)\n",
+ "Tc=15; #alone time of C(days)\n",
+ "a=2; #number of days after A started(days)\n",
+ "b=3; #number of days before the work finished(days)\n",
+ "\n",
+ "#Calculation\n",
+ "L1=Ta*Tb/gcd(Ta,Tb); #lcm of Ta and Tb\n",
+ "L=L1*Tc/gcd(L1,Tc); #lcm of all the three\n",
+ "l1=L/Ta;\n",
+ "l2=L/Tb;\n",
+ "l3=L/Tc;\n",
+ "r=1-a/Ta;\n",
+ "T=((r*L)+Tc)/(l2+l3); #total work finished(days)\n",
+ "TB=T-a; #number of days B worked for(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"total work is finished in\",T,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.11, Page number 11.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "A left after 3.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "T1=15; #alone time of A(days)\n",
+ "T2=10; #alone time of B(days)\n",
+ "a=5; #number of days for B to finish(days)\n",
+ "\n",
+ "#Calculation\n",
+ "L=T1*T2/gcd(T1,T2); #lcm of T1 and T2\n",
+ "l1=L/T1;\n",
+ "l2=L/T2;\n",
+ "x=(L-(l2*a))/(l1+l2); #A left after days(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"A left after\",x,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.12, Page number 11.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "C can do it alone in 25.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "T1=12; #alone time of A(days)\n",
+ "T2=15; #alone time of B(days)\n",
+ "T=2; #number of days they work together(days)\n",
+ "t=5; #number of days work is completed(days)\n",
+ "\n",
+ "#Calculation\n",
+ "Ta=(1+T+t)*(1/T1); #A's amount of work\n",
+ "Tb=T*(1/T2); #B's amount of work\n",
+ "T3=1-(Ta+Tb);\n",
+ "t3=t/T3; #C can do it in(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"C can do it alone in\",t3,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.13, Page number 11.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount received by C is 5.33 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "p=25; #amount paid(Rs)\n",
+ "A=32; #number of days for A(days)\n",
+ "B=20; #number of days for B(days)\n",
+ "C=12; #number of days for C(days)\n",
+ "D=24; #number of days for B(days)\n",
+ "\n",
+ "#Calculation\n",
+ "l1=A*B/gcd(A,B); #lcm of A and B\n",
+ "l2=C*D/gcd(C,D); #lcm of C and D\n",
+ "L=l1*l2/gcd(l1,l2); #LCM of A,B,C and D\n",
+ "a=L/A;\n",
+ "b=L/B;\n",
+ "c1=(1/C)-(1/B);\n",
+ "c=L*c1;\n",
+ "d=L/D;\n",
+ "Cs=c*p/(a+b+c+d); #amount received by C(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"amount received by C is\",round(Cs,2),\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.14, Page number 11.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken to finish the job if A starts the work is 5.8 days\n",
+ "time taken to finish the job if B starts the work is 5.86 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "tA=5; #work for A alone(days)\n",
+ "tB=7; #work for B alone(days)\n",
+ "\n",
+ "#Calculation\n",
+ "p=round(tA*tB/(tA+tB)); #nearest integer value\n",
+ "Ta=((tA*tB)+(p*(tA-tB)))/tA; #time taken to finish the job if A starts the work(days)\n",
+ "Tb=((tA*tB)-(p*(tA-tB)))/tB; #time taken to finish the job if B starts the work(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken to finish the job if A starts the work is\",Ta,\"days\"\n",
+ "print \"time taken to finish the job if B starts the work is\",round(Tb,2),\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "## Example number 11.15, Page number 11.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "job is finished in 15.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "tA=20; #number of days for A(days)\n",
+ "tB=30; #number of days for B(days)\n",
+ "tC=60; #number of days for C(days)\n",
+ "da=3; #help done by A\n",
+ "db=1;\n",
+ "dc=1;\n",
+ "\n",
+ "#Calculation\n",
+ "t=(da/tA)+(db/tB)+(dc/tC);\n",
+ "T=da/t; #job is finished in(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"job is finished in\",T,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.16, Page number 11.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "job is finished in 30.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "K=3;\n",
+ "l=80; #number of days\n",
+ "\n",
+ "#Calculation\n",
+ "T=K*l/((K**2)-1); #job is finished in(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"job is finished in\",T,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.17, Page number 11.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken if they work together is 12.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "tA=20; #work by skilled men(days)\n",
+ "tB=30; #work by boys(days)\n",
+ "\n",
+ "#Calculation\n",
+ "T=tA*tB/(tA+tB); #time taken if they work together(days) \n",
+ "\n",
+ "#Result\n",
+ "print \"time taken if they work together is\",T,\"days\""
+ ]
+ }
+ ],
+ "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
+}
|