Welcomes the user to the Travel Time Calculator. Asks user for number of miles traveled(allow user to enter fractional values) Asks user for the speed in miles per hour (allow user to enter fractional values) Calculates the number of hours and minutes for the trip to the nearest integer value. Hint:
my script:
Write a program that calculates the estima#welcome banner
print("Welcome to the Trip Time Calculator") #banner
print()
#ask user for speed/mph and distance in miles
miles = float(input("Enter the miles travled:\t "))
mph = float(input("Enter the miles per hour:\t "))
miles = float(miles)
mph = float(mph)
print()
#print results
#speed=distance/time
#time=distance/speed
#distance=speed*time
print("Estimated traveled time")
hours = (round((miles // mph), ))#t=d/s
minutes = float(round((miles % mph), )) #returns wrong output
print("Hours:\t ", hours,
"\nMinutes: ", minutes)
ted hours and minutes for a trip given the number of miles traveled and the speed in miles per hour.
Specifically, write a program that
- Welcomes the user to the Travel Time Calculator.
- Asks user for number of miles traveled(allow user to enter fractional values)
- Asks user for the speed in miles per hour (allow user to enter fractional values)
- Calculates the number of hours and minutes for the trip to the nearest integer value. Hint: You can use the built-in function round that rounds a given number to the rounded integer value. e.g. round(4) will return 4, round(4.125) will return 4, round(4.5) will return 4 and round (4.75) will return 5.
- Prints the number of hours and minutes for the trip.
Here are some sample runs:
Step by step
Solved in 3 steps with 2 images