summaryrefslogtreecommitdiff
path: root/Quantitative_Aptitude_for_Competitive_Examinations/Chapter19.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'Quantitative_Aptitude_for_Competitive_Examinations/Chapter19.ipynb')
-rwxr-xr-xQuantitative_Aptitude_for_Competitive_Examinations/Chapter19.ipynb866
1 files changed, 866 insertions, 0 deletions
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter19.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter19.ipynb
new file mode 100755
index 00000000..61831463
--- /dev/null
+++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter19.ipynb
@@ -0,0 +1,866 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 19: Time and Distance"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.1, Page number 19.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "distance covered is 700.0 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "s=3.5; #speed(km/h)\n",
+ "t=12/60; #time(hr)\n",
+ "\n",
+ "#Calculation\n",
+ "d=s*t*1000; #distance covered(m)\n",
+ "\n",
+ "#Result\n",
+ "print \"distance covered is\",d,\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.2, Page number 19.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken is 2 hour 45 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d=124; #distance(km)\n",
+ "s=45; #speed(km/h)\n",
+ "\n",
+ "#Calculation\n",
+ "t=d/s; #time(hr)\n",
+ "tm=(t-int(t))*60; #time(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken is\",int(t),\"hour\",int(tm),\"minutes\" "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.3, Page number 19.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken is 5.0 hours\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d=360*1000; #distance(m)\n",
+ "v=20; #velocity(m/s)\n",
+ "\n",
+ "#Calculation\n",
+ "t=d/v; #time taken(min)\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken is\",t/(60*60),\"hours\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.4, Page number 19.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total time taken is 50.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "n=4; #number of rests\n",
+ "tr=5; #time for each rest(min)\n",
+ "d=5; #distance(km)\n",
+ "s=10; #speed(km/hr)\n",
+ "\n",
+ "#Calculation\n",
+ "rt=n*tr; #rest time(min)\n",
+ "t=(d*60/s)+rt; #total time taken(min)\n",
+ "\n",
+ "#Result\n",
+ "print \"total time taken is\",t,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.5, Page number 19.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "usual time is 15.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "abyb=5/7; #factor\n",
+ "deltat=6; #change in time(min)\n",
+ "\n",
+ "#Calculation\n",
+ "bbya=1/abyb; \n",
+ "t=deltat/(bbya-1); #usual time(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"usual time is\",t,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.6, Page number 19.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "usual time is 28.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "abyb=7/6; #factor\n",
+ "deltat=4; #change in time(min)\n",
+ "\n",
+ "#Calculation\n",
+ "bbya=1/abyb; \n",
+ "t=deltat/(1-bbya); #usual time(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"usual time is\",t,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.7, Page number 19.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "distance is 5.0 km\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "t=10+5; #difference in time(min)\n",
+ "v1=4; #speed(km/h)\n",
+ "v2=5; #speed(km/h)\n",
+ "\n",
+ "#Calculation\n",
+ "d=v1*v2*t/60; #distance(km)\n",
+ "\n",
+ "#Result\n",
+ "print \"distance is\",d,\"km\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.8, Page number 19.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "slower speed of train is 25.0 km/h\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "t1=8; #time(hr)\n",
+ "t2=6+(40/60); #time(hr)\n",
+ "d=5; #distance(km)\n",
+ "\n",
+ "#Calculation\n",
+ "v=d/((t1/t2)-1); #slower speed of train(km/h)\n",
+ "\n",
+ "#Result\n",
+ "print \"slower speed of train is\",v,\"km/h\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.9, Page number 19.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "train stops at 15.0 minutes/hour\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "s1=80; #speed(km/h)\n",
+ "s2=60; #speed(km/h)\n",
+ "\n",
+ "#Calculation\n",
+ "st=(s1-s2)/s1; #stoppage time(hr)\n",
+ "\n",
+ "#Result\n",
+ "print \"train stops at\",st*60,\"minutes/hour\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.10, Page number 19.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "distance is 60.0 km\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x=4; #speed(km/h)\n",
+ "a=30/60; #time(hr)\n",
+ "y=2; #speed(km/h)\n",
+ "b=20/60; #time(hr)\n",
+ "\n",
+ "#Calculation\n",
+ "d=(x+y)*(a+b)*a*b*x*y/((b*x)-(a*y))**2; #distance(km)\n",
+ "\n",
+ "#Result\n",
+ "print \"distance is\",d,\"km\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.11, Page number 19.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "distance ran by theif is 800.0 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d=400; #distance(m)\n",
+ "s1=10; #speed(km/h)\n",
+ "s2=15; #speed(km/h)\n",
+ "\n",
+ "#Calculation\n",
+ "x=d*s1/(s2-s1); #distance ran by theif(m)\n",
+ "\n",
+ "#Result\n",
+ "print \"distance ran by theif is\",x,\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.12, Page number 19.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "average speed is 70.0 km/h\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d1=450; #distance(km)\n",
+ "d2=740; #distance(km)\n",
+ "t1=7; #time(hrs)\n",
+ "t2=10; #time(hrs)\n",
+ "\n",
+ "#Calculation\n",
+ "Va=(d1+d2)/(t1+t2); #average speed(km/h)\n",
+ "\n",
+ "#Result\n",
+ "print \"average speed is\",Va,\"km/h\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.13, Page number 19.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "average speed is 48.0 km/h\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "V1=60; #speed(km/h)\n",
+ "V2=40; #speed(km/h)\n",
+ "\n",
+ "#Calculation\n",
+ "Va=2*V1*V2/(V1+V2); #average speed(km/h)\n",
+ "\n",
+ "#Result\n",
+ "print \"average speed is\",Va,\"km/h\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.14, Page number 19.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "average speed is 63 km/h\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "V1=40; #speed(km/h)\n",
+ "V2=60; #speed(km/h)\n",
+ "V3=70; #speed(km/h)\n",
+ "t1=30/60; #time(hrs)\n",
+ "t2=45/60; #time(hrs)\n",
+ "t3=2; #time(hrs)\n",
+ "\n",
+ "#Calculation\n",
+ "Va=((V1*t1)+(V2*t2)+(V3*t3))/(t1+t2+t3); #average speed(km/h)\n",
+ "\n",
+ "#Result\n",
+ "print \"average speed is\",int(Va),\"km/h\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.15, Page number 19.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken to travel is 2.0 hours\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "V1=60; #speed(km/h)\n",
+ "V2=30; #speed(km/h)\n",
+ "d=240; #distance(km)\n",
+ "t=6; #time(hrs)\n",
+ "\n",
+ "#Calculation\n",
+ "Va=d/t; #average speed(km/h)\n",
+ "t60=Va-V2;\n",
+ "t30=V1-Va;\n",
+ "T=t60*t/(t60+t30); #time taken to travel(hours)\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken to travel is\",T,\"hours\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.16, Page number 19.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "distance travelled by car is 140 km\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",
+ "t=2; #time(hrs)\n",
+ "v1=100; #speed(km/h)\n",
+ "v2=50; #speed(km/h)\n",
+ "d=170; #distance(km)\n",
+ "\n",
+ "#Calculation\n",
+ "x=(t*d)-(t*v1); #distance travelled by car(km)\n",
+ "\n",
+ "#Result\n",
+ "print \"distance travelled by car is\",x,\"km\"\n",
+ "print \"answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.17, Page number 19.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total distance is 3.0 km\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "T=42; #total time(min)\n",
+ "v1=4; #speed(km/h)\n",
+ "v2=5; #speed(km/h)\n",
+ "\n",
+ "#Calculation\n",
+ "d=T/(v1+(2*v2)); #total distance(km)\n",
+ "\n",
+ "#Result\n",
+ "print \"total distance is\",d,\"km\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.18, Page number 19.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "original speed is 60.0 km/h\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d=840; #distance(km)\n",
+ "t=2; #time(hrs)\n",
+ "s=10; #speed(km/h)\n",
+ "\n",
+ "#Calculation\n",
+ "x=d*s/(s*t); \n",
+ "y=x/(t*(t+1));\n",
+ "V=d*s/(t*y); #original speed(km/h)\n",
+ "\n",
+ "#Result\n",
+ "print \"original speed is\",V,\"km/h\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.19, Page number 19.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total time taken is 6 1/4 hrs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import Fraction\n",
+ "\n",
+ "#Variable declaration\n",
+ "tx=4+(30/60); #time(hrs)\n",
+ "ty=1+(45/60); #time(hrs)\n",
+ "\n",
+ "#Calculation\n",
+ "T=tx+ty; #total time taken(hrs)\n",
+ "x=T-int(T);\n",
+ "\n",
+ "#Result\n",
+ "print \"total time taken is\",int(T),Fraction(x),\"hrs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.20, Page number 19.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken by A is 100 min\n",
+ "time taken by B is 80 min\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "rA=4;\n",
+ "rB=5; #rates of A and B\n",
+ "t=20; #time(min)\n",
+ "\n",
+ "#Calculation\n",
+ "tB=rA*t; #time taken by B(min)\n",
+ "tA=t*rB; #time taken by A(min)\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken by A is\",tA,\"min\"\n",
+ "print \"time taken by B is\",tB,\"min\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.21, Page number 19.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total time taken is 4.33 hrs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "t=6+(30/60); #time(hrs)\n",
+ "tl=2+(10/60); #time lost(hrs)\n",
+ "\n",
+ "#Calculation\n",
+ "T=t-tl; #total time taken(hrs)\n",
+ "\n",
+ "#Result\n",
+ "print \"total time taken is\",round(T,2),\"hrs\""
+ ]
+ }
+ ],
+ "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
+}