About 1,570,000 results
Open links in new tab
  1. python - Loop Table using distance = speed * time - Stack Overflow

    Sep 30, 2017 · distance = speed * time Write a program that asks the user for the speed of a vehicle (in miles per hour) and how many hours it has traveled. The program should then use a loop to display the distance the vehicle has traveled for each hour of that time period.

  2. Chapter 4 – #4: Distance Traveled – Tony Gaddis – Starting Out With Python

    Jun 22, 2023 · 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 each hour of that time period. speed = int(input("Error: Enter a positve number: ")) . hours = int(input("Error: Enter a positve number: ")) .

  3. Python/Time, Distance, and Speed - Wikiversity

    Jan 18, 2025 · This piece of code can calculate the total distance, time and speed. If you run the code you first enter the values such as the total speed of a car, the time it took and the distance traveled. For example, if you want to find the speed you would enter: The Distance Traveled; The Time (in hours) traveled; Select the speed formula

  4. Displaying calculations using a loop in Python - Stack Overflow

    Jul 19, 2018 · #This program uses a loop to display #distance traveled over time. print('This program calculates distance traveled') print('for a vehicle traveling at a constant speed.') #Gets speed of the vehicle speed = int(input('Enter the vehicle speed in MPH: ')) #Gets the hours hours = int(input('Enter time of trip in hours: ')) #creates headings for ...

  5. Distance Traveled - Python Fiddle

    Apr 16, 2015 · For loop that calculates distance traveled in Miles when user enters speed in MPH and time in hours traveled.

  6. python - How to work out speed from distance as a float and time

    Feb 7, 2017 · Use distance / ( time.total_seconds() / 3600.0 ) (assuming distance is already in km).

  7. Calculate Distance Traveled - Python Program - CodePal

    A Python program that prompts the user to enter the average speed and time traveled by a vehicle, and calculates the distance traveled at each hour of the journey.

  8. Solved Python code only. The distance a vehicle travels can

    Write a program that asks the user for the speed of a vehicle (in miles per hour) and the number 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.

  9. Write a python program to calculate speed in km/hr (speed = distance

    Oct 3, 2021 · A python program to calculate speed in km/hr: distance = float(input("Enter the distance in km: ")) time = float(input("Enter the time in hours: ")) speed = distance/time. print("The speed is {:.2f} km/hr".format(speed)) The distance and time variables are declared and their values are obtained from the user using the input() function.

  10. Chapter 2 – #5: Distance Traveled – Tony Gaddis – Starting Out With Python

    May 14, 2020 · Assuming there are no accidents or delays, the distance that a car travels down the inter- state can be calculated with the following formula: Distance= Speed * Time. A car is traveling at 70 miles per hour. Write a program that displays the following: • The distance the car will travel in 6 hours • The distance the car will travel in 10 hours

  11. Some results have been removed