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:
When writing your program, also be sure to:
When you are finished, please submit the .py file for the assignment on Canvas.
Copyright © 2024 Ian Finlayson | Licensed under a Creative Commons BY-NC-SA 4.0 License.