- Problem
- solution.py

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 function that takes the speed of a vehicle and the number of hours it has traveled. It should then use a loop to display the distance the vehicle has traveled for each hour of that time period. It then shows the accumulated distance at

the end. Ask the user for the speed of a vehicle and the number of hours it has traveled.

Here is an example of the desired output:

speed = int(input(“Enter the speed of the vehicle in mph: “))

hour = int(input(“Enter the number of hours traveled: “))

print(“Hour Distance Traveled”)

print(“———————————-“)

def table(speed, hour):

sum = 0

for i in range(1, hour+1):

x = float((i) * speed)

sum = sum + x

print(i,” “,x)

print(“The accumalated distance traveled is: “, sum)

table(speed, hour)

© All Rights Reserved by Rezaul Islam @inksway.com