Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Second International Conference Acids Hue City Vietnam March 2010 Proceedings Part 1 Lnai 5990

Authors: Manh Thanh Le ,Jerzy Swiatek ,Ngoc Thanh Nguyen

2010th Edition

3642121446, 978-3642121449

More Books

Students also viewed these Databases questions

Question

Presentations Approaches to Conveying Information

Answered: 1 week ago