Question: Write a Python program that will compute and print the miles per gallon(mpg) for a car over a trip. The program will ask for the

Write a Python program that will compute and print the miles per gallon(mpg) for a car over a trip. The program will ask for the following:

  1. Odometer reading at the beginning of the trip in miles

  2. Odometer reading at the end of the trip in miles

  3. Amount of gasoline at the beginning of the trip in gallons

  4. Amount of gasoline remaining when the trip ended in gallons

A user session of the program proceeds as follows:

Program Prompt: Enter the odometer reading at the start of the trip in miles

User Response: 100.5

Program Prompt: Enter the odometer reading at the end of the trip in miles

User Response: 200.5

Program Prompt: Enter the amount of gasoline at the start of the trip in gallons

User Response: 20.1

Program Prompt: Enter the amount of gasoline at the end of the trip in gallons

User Response: 17.1

Program Prints:

Miles per gallon for the car is 33.33

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!