Write a program that asks the user how many miles they ran and how many minutes it took to run that far. Ask for the input in this order!Convert their speed to miles per hour and print out their speed.Be sure to include comments that describe the program’s behavior which is how the program functions and how the user interacts with it.Sample output:How many miles did you run? 3How many minutes did it take you? 60Speed in mph: 3.0
Question
Write a program that asks the user how many miles they ran and how many minutes it took to run that far. Ask for the input in this order!Convert their speed to miles per hour and print out their speed.Be sure to include comments that describe the program’s behavior which is how the program functions and how the user interacts with it.Sample output:How many miles did you run? 3How many minutes did it take you? 60Speed in mph: 3.0
Solution
Sure, here is a Python program that does what you asked for:
# This program calculates the speed in miles per hour
# Ask the user for the number of miles they ran
miles = float(input("How many miles did you run? "))
# Ask the user for the number of minutes it took
minutes = float(input("How many minutes did it take you? "))
# Convert minutes to hours
hours = minutes / 60
# Calculate the speed in miles per hour
speed = miles / hours
# Print the speed
print("Speed in mph:", speed)
This program first asks the user to input the number of miles they ran and the time it took in minutes. It then converts the time from minutes to hours and calculates the speed by dividing the distance by the time. Finally, it prints out the calculated speed.
Similar Questions
Given that distance = speed x time, write a program that asks for the user for a speed (in mph) and time (in hours) and will calculate and report how far that person can travel going that speedfor the provided time.The program should accept and correctly utilize fractional (i.e. decimal) inputs.
Write a program that takes the speed (in km/h) and the time (in hours) as input and calculates the distance traveled using the formula: distance = speed * time.Create a class called Distance with speed and time as public attributes. Using a friend function, the program should calculate the total distance.Input format :The input consists of two integers: speed and time separated by a space.
Samuel recently ran a marathon. It took him 4.9 hours to run the 26.6 miles required to complete a marathon. Find his average speed in miles per hour. Then convert his speed to feet per second. (Hint: 1 mile = 5,280 feet).(Round your answers to two decimal places)
lex is an aspiring marathon runner with a constant speed of 8 miles per hour. Alex is determined to achieve a distance of at least 20 miles during his training sessions. Help Alex create a program that takes the running time as input and outputs whether he can cover the required distance within that time.The program should utilize ternary and relational operators to make the determination and display the results.Note: Required distance = speed * running timeInput format :The input consists of a float value 'f', representing Alex's running time in hours.Output format :The output displays whether he can or cannot cover 20 miles in the following format: "Alex [can/cannot] cover at least 20 miles."Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:0.0 ≤ f ≤ 5.0
Melissa is driving along a highway at a constant speed of 65 miles per hour.How long does it take her to travel 90 miles? Make sure to convert the answer into hours and minutes.An hour and 48 minutesAn hour and 18 minutesAn hour and 33 minutesAn hour and 23 minutes
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.