Home CPSC 110

Trip Estimator


Due: February 10



To gain experience writing programs in Python including the use of input, output, variables, and simple math.



For this program, you will write a program that calculates how long it should take to get from point A to point B. This would be useful if you wanted to know whether you had time to walk to your favorite restaurant or coffee shop or whether you should settle for something closer.

For example, the distance between UMW and Hyperion coffee downtown is 0.9 miles. If you're walking quickly you can walk 4 miles per hour. (Or you might walk at a more leisurely pace of 3 miles per hour. Or you might want to run to mix your cardio with your snack run.)

The laws of physics tell us:

$Speed = \frac{Distance}{Time}$

$Distance = Speed \times Time$

$Time = \frac{Distance}{Speed}$

So if I need to travel the 0.9 miles at a speed of 4 miles per hour, it will take me approximately 13.5 minutes to arrive.

If I walk at a more leisurely pace, my speed will be 3 miles per hour. This would give me an estimated travel time of 18 minutes.

If I drive the same route, I might travel an average of 25 miles per hour and it will take me 2.16 minutes to arrive.

Your program should ask the user for the distance they need to travel, and also what speed they will be travelling at. It should then tell them the approximate travel time based on those things.

This same type of calculation is used in Google Maps when you calculate driving time for directions!



Your program should do the following things:

  1. Welcome the user to the program and state the purpose of the program.
  2. Ask the user to enter the distance they will be travelling. Make the prompt clear and tell them what units to enter.
  3. Ask them for the speed they walk at, again making the prompt clear on units.
  4. Use arithmetic expressions to calculate the amount of travel time required. Be sure that the answer is expressed in minutes, not hours.
  5. Communicates the result to the user along with a clear label.


General Requirements

When writing your program, also be sure to:



When you are finished, please submit the .py file for the assignment on Canvas.

Copyright © 2022 Ian Finlayson | Licensed under a Attribution-NonCommercial 4.0 International License.