Question

The distance a a travels can be calculated as follows: vehicle ls 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 each hour of that time period. Here is an example of the desired output: What is the speed of the vehicle in mph? 40 How many hours has it traveled? 3 Hour Distance Traveled 40 80 3 120

Please have it written in Python.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

speed = int(input("What is the speed of the vehicle in mph? "))
n = int(input("How many hours has it traveled? "))
print("Hour\tDistance Travelled")
print("----\t------------------")
for i in range(1,n+1):
    print(str(i)+"\t\t"+str(i*speed))

Add a comment
Know the answer?
Add Answer to:
Please have it written in Python. The distance a vehicle travels can be calculated as follows:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The distance a vehicle travels can be  calculated as follows: distance = speed * time. For...

    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...

  • The speed of a vehicle is inversely proportional to the time it takes to travel a...

    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

  • Please help me to try to better understand how to write an algorithm and then write...

    Please help me to try to better understand how to write an algorithm and then write the code in C language. Create a flowchart for the design to perform the following task and then implement a program that computes the distance traveled by a car moving at a constant speed for a specific amount of time. This program must understand different units of measurement for speed, time, and distance. The algorithm will ask the user for the following information: The...

  • PLEASE HELP WITH CODE PYTHON BASE.!!!!!!!! Tasks: Complete the following programs noted below: Problem 1: A...

    PLEASE HELP WITH CODE PYTHON BASE.!!!!!!!! Tasks: Complete the following programs noted below: Problem 1: A painting company has determined that for 112 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $35.00 per hour for labor. Write a program that asks the user to enter the square feet of wall space to be painted and the price of paint per gallon. The program should display the following data:...

  • USING PYTHON IDLE 3.4: NEED HELP WITH THIS PLEASE! :( Question #8: You want to determine...

    USING PYTHON IDLE 3.4: NEED HELP WITH THIS PLEASE! :( Question #8: You want to determine the distance to lightning strikes during a storm. This can be measured using the time elapsed between seeing the lightning flash and hearing the thunder. You know that the speed of sound is approximately 1,100 ft/second and 1 mile is 5,280 feet. Write a program named q8.py that prompts the user for the number of lightning strikes to analyze and the number of seconds...

  • Write a Python program that does the following: Obtains the following input from a user: Mileage...

    Write a Python program that does the following: Obtains the following input from a user: Mileage at beginning of measurement period Mileage at end of measurement period Gallons of fuel consumed Calculates and displays: Miles driven Miles per gallon Kilometers driven Liters of fuel consumed Kilometers per liter Incorporate some Selection structure logic into it: If a vehicle gets less than 15 miles per gallon, display the message:       "Your vehicle has criminally low fuel efficiency." If it gets 15...

  • just the extra credit part please Your customer needs an automated system to patrol the highways....

    just the extra credit part please Your customer needs an automated system to patrol the highways. The job of the system is to collect the following information on vehicles traveling down a certain stretch of highway: license plate number, current speed, and speed limit. A program is required to determine if a speeding ticket is needed for each set of data. Ticket will only be issued when number of miles per hours (mph) over the speed limit is at least...

  • 1. Which graph best describes the "horizontal distance traveled" (vertical axis) versus the tim elapsed (horizontal...

    1. Which graph best describes the "horizontal distance traveled" (vertical axis) versus the tim elapsed (horizontal axis) for a car traveling at a constant speed of 60 miles per hour? Write down the letter and then justify your answer in a complete sentence Horizontal Position of Car (in miles) Answer: 240 Bapsed Time in hours) 120 2. (a) Sketch the speed in milòs per hour (mi/ h) versus time in hours for Problem #1. on - Speed of Car (miles...

  • Python)) Data types of Python. Write the python script to show the different examples. Write the...

    Python)) Data types of Python. Write the python script to show the different examples. Write the Python script to present ALL the mathematical arithmetic operations. Write the Python script to display your - first name, last name, ID, college name and the program of study. Write the Python script to receive the number of seconds as input and display the hours, minutes and seconds as output. Assume the variable x to be with the string of "Day by day, dear...

  • import java.util.Scanner; public class MPGMain {    public static void main(String[] args)    {       ...

    import java.util.Scanner; public class MPGMain {    public static void main(String[] args)    {        Scanner input = new Scanner(System.in);               Mileage mileage = new Mileage();               System.out.println("Enter your miles: ");        mileage.setMiles(input.nextDouble());               System.out.println("Enter your gallons: ");        mileage.setGallons(input.nextDouble());               System.out.printf("MPG : %.2f",mileage.getMPG());           } } public class Mileage {    private double miles;    private double gallons;    public double getMiles()...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT