Click here to Skip to main content
14,773,407 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Couldn’t write down the program.
If you run a race with 10 kilometer in 43 minutes 30 seconds, Write a program that satisfies the following requirements.

a) Store all given inputs in variables (distance, and time).

b) Calculate the average speed in kilometer per minutes, print the output.

c) Calculate the time in seconds.

d) Calculate the average speed in kilometer per seconds, print the output.

e) Write a function converts from kilometer to miles.

(Hint: there are 1.61 kilometers in a mile).



f) Calculate the average speed in miles per minute? print the output.

What I have tried:

Tried to solve but couldn’t.
By using Python 3
Posted
Updated 10-Jun-20 21:55pm
Comments
PIEBALDconsult 10-Jun-20 16:52pm
   
We won't do your homework.

First of all, congratulations! 43'30" it is a pretty good time for running 10 km. :-)
Then, let's start with the program
# point (1)
distance = 10 # distance in kilometers
minutes = 43.5 # time in minutes
# point (2)
average_speed = distance / minutes # average speed in kilometers per minute
print("average speed {:6.3f} km/min".format(average_speed))
# ...

Now, completing it is up to you.
   
I have the solution for you
Following Python code is the solution to your problem statement :

#a) Store all given inputs in variables (distance, and time).
distance=float(input("Enter the Distance : "))
time=float(input("Enter the time in minutes : "))

#b) Calculate the average speed in kilometer per minutes, print the output.
average_speed=distance/time
print("Average speed in kilometer per minutes : ",average_speed)

#c) Calculate the time in seconds.
seconds=time*60
print("Time In Seconds : ",seconds)

#d) Calculate the average speed in kilometer per seconds, print the output.
kmperseconds=average_speed/60
print("Average speed in kilometer per seconds : ",kmperseconds)

#e) Write a function converts from kilometer to miles.
#(Hint: there are 1.61 kilometers in a mile).

def kilometersToMiles(distance):
    return distance/1.61
print("Kilometers to Miles : ",kilometersToMiles(distance))

#f) Calculate the average speed in miles per minute? print the output.
avgspeedInMiles=kilometersToMiles(distance)/time
print("Average Speed In Miles Per Minutes : ",avgspeedInMiles)
   
Comments
Richard MacCutchan 11-Jun-20 4:31am
   
Writing people's complete assignments for them is not helpful. Either to them, or future posters, who think CodeProject provides an assignment writing service.
ishan_shah 15-Jun-20 1:50am
   
Sorry, sir. Next time I will keep awareness to post only a particular point or question's answer instead of post the whole assignment

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900