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:
-
Odometer reading at the beginning of the trip in miles
-
Odometer reading at the end of the trip in miles
-
Amount of gasoline at the beginning of the trip in gallons
-
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
Get step-by-step solutions from verified subject matter experts
