Question: I have to write a Python 3 program that is looking to figure out the following information : (1) Miles ran, converted from kilometers (2)

I have to write a Python 3 program that is looking to figure out the following information :

(1) Miles ran, converted from kilometers

(2) Average pace per mile

(3) Average miles per hour.

In order to perform the conversions above, I need to obtain the following user inputs:

(1) Number of kilometers ran, a floating-point number

(2) Number of hours, a whole number

(3) Number of minutes, a whole number

The test case I will use for this code will be for a runner who ran 10 kilometers in 1 hour and 1 minute. If done correctly, the output should result with 6.21 miles, 9:49 pace, and 6.11 MPH.

So far, I have the following code for the user input:

distance = float (input ("Enter distance ran ")) hours = int (input ("Enter hours ran ")) minutes = int (input ("Enter minutes ran ")) print (distance + " km, " + hours + " hours, " + minutes + " minutes")

On the output screen, it reads the following:

Enter distance ran 10

Enter hours ran 1

Enter minutes ran 1

I need help writing the code that will have the following output:

You ran 6.21 miles

Your pace: 9 min 49 sec per mile

Your MPH: 6.11

Some other things to note:

There are 1.61 kilometers in a mile.

The number of miles and average miles per hour should be rounded off to two decimal places

Python's math library has a floor function if needed, and can be accessed through writing import math at the top of the .py file.

If a calculation is done that says 10.8 minutes, that does not mean 10 minutes and 80 seconds, but rather 8/10 minutes, so a conversion would need to be made to minutes and seconds.

Use a constant variable to store the number of kilometers in a mile

Use round or format functions only for printing out, and do not save any values that have been rounded off, floored, etc.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!