19: Time and Distance

Example number 19.1, Page number 19.5

In [1]:
#importing modules
import math
from __future__ import division

#Variable declaration
s=3.5;      #speed(km/h)
t=12/60;    #time(hr)

#Calculation
d=s*t*1000;     #distance covered(m)

#Result
print "distance covered is",d,"m"
distance covered is 700.0 m

Example number 19.2, Page number 19.5

In [2]:
#importing modules
import math
from __future__ import division

#Variable declaration
d=124;     #distance(km)
s=45;      #speed(km/h)

#Calculation
t=d/s;      #time(hr)
tm=(t-int(t))*60;     #time(minutes)

#Result
print "time taken is",int(t),"hour",int(tm),"minutes"    
time taken is 2 hour 45 minutes

Example number 19.3, Page number 19.5

In [3]:
#importing modules
import math
from __future__ import division

#Variable declaration
d=360*1000;     #distance(m)
v=20;      #velocity(m/s)

#Calculation
t=d/v;     #time taken(min)

#Result
print "time taken is",t/(60*60),"hours"
time taken is 5.0 hours

Example number 19.4, Page number 19.5

In [4]:
#importing modules
import math
from __future__ import division

#Variable declaration
n=4;    #number of rests
tr=5;    #time for each rest(min)
d=5;    #distance(km)
s=10;   #speed(km/hr)

#Calculation
rt=n*tr;   #rest time(min)
t=(d*60/s)+rt;   #total time taken(min)

#Result
print "total time taken is",t,"minutes"
total time taken is 50.0 minutes

Example number 19.5, Page number 19.5

In [5]:
#importing modules
import math
from __future__ import division

#Variable declaration
abyb=5/7;    #factor
deltat=6;    #change in time(min)

#Calculation
bbya=1/abyb;      
t=deltat/(bbya-1);     #usual time(minutes)

#Result
print "usual time is",t,"minutes"
usual time is 15.0 minutes

Example number 19.6, Page number 19.5

In [6]:
#importing modules
import math
from __future__ import division

#Variable declaration
abyb=7/6;    #factor
deltat=4;    #change in time(min)

#Calculation
bbya=1/abyb;      
t=deltat/(1-bbya);     #usual time(minutes)

#Result
print "usual time is",t,"minutes"
usual time is 28.0 minutes

Example number 19.7, Page number 19.6

In [8]:
#importing modules
import math
from __future__ import division

#Variable declaration
t=10+5;     #difference in time(min)
v1=4;    #speed(km/h)
v2=5;    #speed(km/h)

#Calculation
d=v1*v2*t/60;     #distance(km)

#Result
print "distance is",d,"km"
distance is 5.0 km

Example number 19.8, Page number 19.6

In [9]:
#importing modules
import math
from __future__ import division

#Variable declaration
t1=8;     #time(hr)
t2=6+(40/60);     #time(hr)
d=5;     #distance(km)

#Calculation
v=d/((t1/t2)-1);     #slower speed of train(km/h)

#Result
print "slower speed of train is",v,"km/h"
slower speed of train is 25.0 km/h

Example number 19.9, Page number 19.6

In [10]:
#importing modules
import math
from __future__ import division

#Variable declaration
s1=80;    #speed(km/h)
s2=60;    #speed(km/h)

#Calculation
st=(s1-s2)/s1;     #stoppage time(hr)

#Result
print "train stops at",st*60,"minutes/hour"
train stops at 15.0 minutes/hour

Example number 19.10, Page number 19.7

In [11]:
#importing modules
import math
from __future__ import division

#Variable declaration
x=4;     #speed(km/h)
a=30/60;    #time(hr)
y=2;    #speed(km/h)
b=20/60;    #time(hr)

#Calculation
d=(x+y)*(a+b)*a*b*x*y/((b*x)-(a*y))**2;        #distance(km)

#Result
print "distance is",d,"km"
distance is 60.0 km

Example number 19.11, Page number 19.7

In [12]:
#importing modules
import math
from __future__ import division

#Variable declaration
d=400;     #distance(m)
s1=10;     #speed(km/h)
s2=15;     #speed(km/h)

#Calculation
x=d*s1/(s2-s1);     #distance ran by theif(m)

#Result
print "distance ran by theif is",x,"m"
distance ran by theif is 800.0 m

Example number 19.12, Page number 19.7

In [13]:
#importing modules
import math
from __future__ import division

#Variable declaration
d1=450;       #distance(km)
d2=740;       #distance(km)
t1=7;         #time(hrs)
t2=10;        #time(hrs)

#Calculation
Va=(d1+d2)/(t1+t2);     #average speed(km/h)

#Result
print "average speed is",Va,"km/h"
average speed is 70.0 km/h

Example number 19.13, Page number 19.7

In [14]:
#importing modules
import math
from __future__ import division

#Variable declaration
V1=60;      #speed(km/h)
V2=40;      #speed(km/h)

#Calculation
Va=2*V1*V2/(V1+V2);     #average speed(km/h)

#Result
print "average speed is",Va,"km/h"
average speed is 48.0 km/h

Example number 19.14, Page number 19.7

In [15]:
#importing modules
import math
from __future__ import division

#Variable declaration
V1=40;      #speed(km/h)
V2=60;      #speed(km/h)
V3=70;      #speed(km/h)
t1=30/60;         #time(hrs)
t2=45/60;        #time(hrs)
t3=2;         #time(hrs)

#Calculation
Va=((V1*t1)+(V2*t2)+(V3*t3))/(t1+t2+t3);     #average speed(km/h)

#Result
print "average speed is",int(Va),"km/h"
average speed is 63 km/h

Example number 19.15, Page number 19.8

In [16]:
#importing modules
import math
from __future__ import division

#Variable declaration
V1=60;      #speed(km/h)
V2=30;      #speed(km/h)
d=240;      #distance(km)
t=6;        #time(hrs)

#Calculation
Va=d/t;     #average speed(km/h)
t60=Va-V2;
t30=V1-Va;
T=t60*t/(t60+t30);      #time taken to travel(hours)

#Result
print "time taken to travel is",T,"hours"
time taken to travel is 2.0 hours

Example number 19.16, Page number 19.8

In [17]:
#importing modules
import math
from __future__ import division

#Variable declaration
t=2;     #time(hrs)
v1=100;    #speed(km/h)
v2=50;     #speed(km/h)
d=170;     #distance(km)

#Calculation
x=(t*d)-(t*v1);      #distance travelled by car(km)

#Result
print "distance travelled by car is",x,"km"
print "answer given in the book is wrong"
distance travelled by car is 140 km
answer given in the book is wrong

Example number 19.17, Page number 19.8

In [18]:
#importing modules
import math
from __future__ import division

#Variable declaration
T=42;     #total time(min)
v1=4;    #speed(km/h)
v2=5;     #speed(km/h)

#Calculation
d=T/(v1+(2*v2));     #total distance(km)

#Result
print "total distance is",d,"km"
total distance is 3.0 km

Example number 19.18, Page number 19.9

In [19]:
#importing modules
import math
from __future__ import division

#Variable declaration
d=840;     #distance(km)
t=2;     #time(hrs)
s=10;    #speed(km/h)

#Calculation
x=d*s/(s*t);    
y=x/(t*(t+1));
V=d*s/(t*y);      #original speed(km/h)

#Result
print "original speed is",V,"km/h"
original speed is 60.0 km/h

Example number 19.19, Page number 19.9

In [23]:
#importing modules
import math
from __future__ import division
from fractions import Fraction

#Variable declaration
tx=4+(30/60);      #time(hrs)
ty=1+(45/60);      #time(hrs)

#Calculation
T=tx+ty;        #total time taken(hrs)
x=T-int(T);

#Result
print "total time taken is",int(T),Fraction(x),"hrs"
total time taken is 6 1/4 hrs

Example number 19.20, Page number 19.9

In [24]:
#importing modules
import math
from __future__ import division

#Variable declaration
rA=4;
rB=5;     #rates of A and B
t=20;     #time(min)

#Calculation
tB=rA*t;   #time taken by B(min)
tA=t*rB;   #time taken by A(min)

#Result
print "time taken by A is",tA,"min"
print "time taken by B is",tB,"min"
time taken by A is 100 min
time taken by B is 80 min

Example number 19.21, Page number 19.10

In [28]:
#importing modules
import math
from __future__ import division

#Variable declaration
t=6+(30/60);      #time(hrs)
tl=2+(10/60);      #time lost(hrs)

#Calculation
T=t-tl;        #total time taken(hrs)

#Result
print "total time taken is",round(T,2),"hrs"
total time taken is 4.33 hrs