Question: Create a Python program that: Collects the user's: Car make Car model year Car model Number of miles driven on the last trip Amount of

Create a Python program that:

  • Collects the user's:
    • Car make
    • Car model year
    • Car model
    • Number of miles driven on the last trip
    • Amount of fuel used on the last trip (gallons)
  • Calculates fuel mileage achieved on the trip (miles/fuelused)
  • Display the vehicle's model year, make, and model on a singleline separated by spaces
  • Display fuel mileage on a separate line
  • If the calculated fuel mileage is 25 miles/gallon or better,display the message "Fuel Efficient" beside the calculated fuelmileage; if the calculated mileage is less than 25 miles/gallon,display the message "Gas Guzzler" beside the calculated fuelmileage.
  • Calculates the average mileage for any number of mileageentries
    • Create a loop that will execute as many times as the userdesires
    • Prompt the user to enter the gas mileage for a trip
    • Ask the user if they have any more trip mileages they wish toenter
      • Stop the loop when the user does not wish to add moretrips
      • Use an if statement to test the user's response
    • Calculate the average mileage from all of the trips and displayit

I have a program written from a previous assignment that gets meto the point of displaying the fuel mileage on a separate line. Ineed help with the remaining portion of the code. I am copying mycode from the previous assignment below for reference:

CarMake = '' #Creates a variable to store the car make andintitializes it as a string
CarModelYear = 0 #Creates a variable to store the car model yearand initializes it as a number
CarModel = '' #Creates a variable to store the car model andinitializes it as a string
MilesDriven = 0 #Creates a variable to store the miles driven onthe last trip and initializes it as a number
FuelUsed = 0 #Creates a variable to store the amount of fuel usedduring the last trip and initializes it as a number
VehicleInfo = '' #Creates a variable to store the make, year andmodel of the vehicle and initializes it as a string
MilesPerGallon = 0 #Creates a variable to store the miles pergallon and initializes it as a number
CarMake = input('Please enter vehicle make: ') #Collects thevehicle make information and assigns it to the CarMakevariable
CarModelYear = input('Please enter the model year: ') #Collects thevehicle model year information and assigns it to the CarModelYearvariable
CarModel = input('Please enter the vehicle model: ') #Collects thevehicle model information and assigns it to the CarModelvariable
MilesDriven = int(input('Please enter the miles driven during yourlast trip: ')) #Collects the amount of miles drive on the lasttrip, converts to an integer and assigns it to the MilesDrivenvariable
FuelUsed = int(input('Please enter the amount of fuel, in gallons,used during your last trip: ')) #Collects the amount of fuel usedduring the last trip, converts to an integer and assigns it to theFuelUsed variable
VehicleInfo = CarModelYear + ' ' + CarMake + ' ' + CarModel#Concatenates the vehicle information with spaces in between andassigns the result to the VehicleInfo variable
MilesPerGallon = MilesDriven/FuelUsed #divides the amount of fuelused by the miles driven to give the miles per gallon and thenassigns the results to the MilesPerGallon variable
print(VehicleInfo) #prints the vehicle information in a single linewith spaces in between
print(MilesPerGallon) #prints the miles per gallon of the fuel usedfor the trip information entered.

Step by Step Solution

3.37 Rating (144 Votes )

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 Programming Questions!