SharedClass Samples / calculate-drive-time.pyOpen in CoCalc
Authors: Barry Bandstra, Ryan McFall
1
distance_to_travel = float(raw_input('How far are you going? '))
2
speed_limit = float(raw_input('What is the speed limit? '))
3
minutes_to_save = float(raw_input('How many minutes do you want to save? '))
4
5
numerator = (speed_limit * minutes_to_save * speed_limit) / (distance_to_travel * 60)
6
denominator = 1 - (speed_limit * minutes_to_save) / (distance_to_travel * 60)
7
8
new_speed = (numerator / denominator) + speed_limit
9
10
print 'You should go', new_speed, 'to save', minutes_to_save, 'minutes over going', speed_limit,
11
print 'when traveling', distance_to_travel, 'miles'
12