The distance a vehicle travels can be
calculated as follows:
distance = speed * time.
For example, if a train travels 40 miles per hour for
three hours, the distance traveled is 120 miles. Write a program
using python that asks the user for the speed of a vehicle in mph
and the number of hours it has traveled. It should then use a while
loop to display
the distance the vehicle has traveled for each hour of that time
period.
Be sure to use input, format, and while loop correctly. Here's an
example
Enter the speed of the vehicle in mph: 40
Enter the number of hours traveled: 3
Hours Distance Traveled
-----------------------------------------------------------
1
40
2
80
3
120
Python Program:
def main():
"""
Python program that calculates the
distance a vehicle travelled
"""
# Reading speed
speed = int(input("\n Enter the speed of the vehicle
in mph: "));
# Reading time
hours = int(input("\n\n Enter the number of hours
travelled: "));
# Variable for running for time
hour = 1;
print("\n\n %-10s %-10s \n" %("Hours", "Distance
Travelled"));
print("\n_________________________________________");
# Iterating over while loop
while hour <= hours:
# Calculating speed using formula
distance = speed * time
distance = speed * hour;
#Printing result
print("\n %-10d %-10d " %(hour,
distance));
# Incrementing hours
hour += 1;
print("\n\n");
# Calling main function
main();
________________________________________________________________________________________________
Sample Output:
The distance a vehicle travels can be calculated as follows: distance = speed * time. For...
Please have it written in Python. The distance a vehicle travels can be calculated as follows: distance 5 speed 3 time For example, if a train travels 40 miles per hour for three hours, the distance traveled is 120 miles. Write a program that asks the user for the speed of a vehicle (in miles per hour) and the number of hours it has traveled. It should then use a loop to display the distance the vehicle has traveled for...
The speed of a vehicle is inversely proportional to the time it takes to travel a fixed distance. If a vehicle travels a fixed distance at 60 miles per hour in 20 minutes, how fast must it travel to cover the same distance in 10 minutes? A. 120 mph 1 OB. 30 mph OC. 30 mph 10 OD mph
Solve the following using the 5-step process. The speed of a freight train is 75 mph slower than the speed of a passenger train. The freight train travels 340 miles in the same time that it takes the passenger train to travel 490 miles. Find the speed of each train. Instructions: Enter your answer as a whole number, fraction, or radical. When entering units, type without capitals e.g. mph, feet, meters, yards, etc. The freight train is travelling at Number...
Use a system of linear equations with two variables and two equations to solve. A jeep and BMW enter a highway running east-west at the same exit heading in opposite directions. The jeep entered the highway 30 minutes before the BMW did, and traveled 4 mph slower than the BMW. After 3 hours from the time the BMW entered the highway, the cars were 441 miles apart. Find the speed of each car, assuming they were driven on cruise control....
Solve the following using the 5-step process. The speed of a freight train is 45 mph slower than the speed of a passenger train. The freight train travels 320 miles in the same time that it takes the passenger train to travel 500 miles. Find the speed of each train Instructions: Enter your answer as a whole number, fraction, or radical. When entering units, type without capitals, eg. mph, feet, meters, yards, etc. The freight train is travelling at Number...
Ships A and B leave port together. For the next two hours, ship A travels at 22 mph in a direction 40 ∘west of north while ship B travels 28 ∘ east of north at 29 mph . What is the distance between the two ships two hours after they depart? What is the speed of ship A as seen by ship B? please answer correctly please
How to write a program in python for "speed violation calculator" with a while loop and if statements. calculate the number of miles over the speed limit and display it. ask for the speed limit and the drivers speed the speed limit should be at least 20 but not greater than 70 if the driver's speed is less then the speed limit the driver was not speeding program should calculator and display the number of mph over the speed limit...
Write a Python program that will ask for distance, then compute the travel time for speed starting at 10 MPH to 90 MPH with an increment of 10. Use the equation t = d/v Where t is the time, d is the distance, and v is the speed of MPH
The average speed of a vehicle on a stretch of Route 134 between 6 A.M. and 10 A.M. on a typical weekday is approximated by the function f(t) = 13t − 26 t + 36 (0 ≤ t ≤ 4) where f (t) is measured in miles per hour, and t is measured in hours, with t = 0 corresponding to 6 A.M. At what time of the morning commute is the traffic moving at the slowest rate? A.M. What...
The total stopping distance Tof a vehicle is T- 6.x+1.5x where T is in feet and x is the speed in miles per hour. Use differentials to approximate the percent change in total stopping distance as speed changes from x-22 to x = 27 miles per hour. Round your answer to one decimal place. 15. a. 41.7% b. 80.0% c. 21.9% d. 122.7% e. 50.3% The total stopping distance Tof a vehicle is T- 6.x+1.5x where T is in feet...