A car is traveling at 60 miles per hour. Write a program that displays the following

Distance Traveled

Assuming there are no accidents or delays, the distance that a car travels down the interstate can be calculated with the following formula:

Distance =   Speed x Time

A car is traveling at 60 miles per hour. Write a program that displays the following:

  • The distance the car will travel in 5 hours
  • The distance the car will travel in 8 hours
  • The distance the car will travel in 12 hours

Solution

#use formula : Distance = Speed(mile per hour) x Time(hour) to

#calculate distance in each scenarios

#calculate distance if the car will travel in 5 hours

distance1 = 60 * 5

#calculate distance if the car will travel in 8 hours

distance2 = 60 * 8

#calculate distance if the car will travel in 12 hours

distance3 = 60 * 12

 

#display distances

 

print(“The distance the car will travel in 5 hours :”,distance1)

print(“The distance the car will travel in 8 hours :”,distance2)

 

print(“The distance the car will travel in 12 hours :”,distance3)