You are on page 1of 1

#Calculate user's distance traveled and use a loop to display the distance traveled

per hour per hour

#declare variables
distance = 0.0
speed = 0.0
time = 0.0
counter = 1.0

#obtain data
speed = int(input('What is the speed of the vehicle in mph? '))
time = int(input('How many hours has it traveled? ' ))

#calculate and print data


while counter <= time:
distance = speed * counter
if counter == 1:
print('Hour: Distance Traveled:')
print(f'{counter:5.0f} {distance:20} miles')
counter += 1
else:
print(f'{counter:5.0f} {distance:20} miles')
counter += 1

You might also like