21: Boats and Streams

Example number 21.1, Page number 21.3

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

#Variable declaration
ds=8;     #speed downstream(km/h)
us=2;     #speed upstream(km/h)

#Calculation
r=(ds+us)/2;     #rate in still water(km/h)
s=(ds-us)/2;     #speed of current(km/h)

#Result
print "rate in still water is",r,"km/h"
print  "speed of current is",s,"km/h"
rate in still water is 5.0 km/h
speed of current is 3.0 km/h

Example number 21.2, Page number 21.3

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

#Variable declaration
ddn=30;     #distance downstream(km)
dup=20;     #distance upstream(km)
tdn=5;      #time downstream(hrs)
tup=5;      #time upstream(hrs)

#Calculation
s=(1/2)*((ddn/tdn)-(dup/tup));      #speed of current(km/h)

#Result
print "speed of current is",s,"km/h"
speed of current is 1.0 km/h

Example number 21.3, Page number 21.3

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

#Variable declaration
d=2;    #distance(km)
tdn=20;    #time downstream(min)
tup=15;    #time upstream(min)

#Calculation
x=(d/2)*((1/tdn)+(1/tup));     #speed in still water(km/min)
x=x*60;      #speed in still water(km/hr)
y=(d/2)*(-(1/tdn)+(1/tup));     #speed of current(km/min)
y=y*60;      #speed of current(km/hr)

#Result
print "speed in still water is",x,"km/hr"
print "speed of current is",y,"km/hr"
speed in still water is 7.0 km/hr
speed of current is 1.0 km/hr

Example number 21.4, Page number 21.3

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

#Variable declaration
r=4;       #rate in still water(km/hr)
tdn=1;     #assume

#Calculation
tup=2*tdn;   
d=(tdn+tup)/(tup-tdn);
s=r/d;      #speed of stream(km/h)

#Result
print "speed of stream is",round(s,1),"km/h"
speed of stream is 1.3 km/h

Example number 21.5, Page number 21.4

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

#Variable declaration
x=6;     #speed in still water(km/hr)
y=2;     #speed of river(km/hr)
t=3;     #time(hrs)

#Calculation
d=t*(x+y)/(1+y);     #distance(km)

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

Example number 21.6, Page number 21.4

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

#Variable declaration
x=15;     #speed in still water(km/hr)
y=13;     #rate of current(km/hr)
t=15/60;    #time(hrs)

#Calculation
d=(x+y)*t;    #distance in downstream(km) 

#Result
print "distance in downstream is",d,"km"
distance in downstream is 7.0 km

Example number 21.7, Page number 21.4

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

#Variable declaration
x=4.5;     #speed in still water(km/hr)
y=1.5;     #rate of current(km/hr)

#Calculation
avgs=(x+y)*(x-y)/x;     #average speed for total journey(km/h)

#Result
print "average speed for total journey is",avgs,"km/h"
average speed for total journey is 4.0 km/h

Example number 21.8, Page number 21.4

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

#Variable declaration
T=55;       #time(min)
c=60;      #conversion factor from min to h
y=2;       #speed of stream(km/h)
d=10;      #distance upstream(km)

#Calculation
a=T/5;    #coefficient of x**2
b=-c*y**2;    #coefficient of x
c=-a*y**2;     #constant
x=(b**2)-(4*a*c);
x1=-b+math.sqrt(x)/(2*a);
x2=-b-math.sqrt(x)/(2*a);

#Result
print "speed of rowing in still water is",int(x2/10)
speed of rowing in still water is 22

Example number 21.9, Page number 21.4

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

#Variable declaration
s=10;   #speed in still water(km/h)
td=91;    #total distance(km)
t=20;    #time(h)

#Calculation
d=t/s;    #distance(km)
y2=(s**2)-td;     
y=math.sqrt(y2);      #flow of river(km/h)

#Result
print "flow of river is",y,"km/h"
flow of river is 3.0 km/h