Python Programming: An Introduction to Computer Science, 3rd Ed.
Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
bartleby

Videos

Question
Book Icon
Chapter 8, Problem 9PE
Program Plan Intro

Fuel efficiency of a multi-leg journey

Program Plan:

  • Declare the “MPG” function.
    • Assign the values to the variables.
    • Check “leg” is not equal to newline.
      • Get the current odometer and amount of gas from the user.
      • In “try” block,
        • Split the odometer reading and amount of gas from the user input and assign it into the separate variables.
        • Increment the “count” value.
        • Calculate the distance traveled.
        • Calculate the MPG for leg.
        • Set the new odometer reading.
        • Display the leg.
        • Add values to trip total.
      • In exception block, break the function.
      • Return the values to the main function.
  • Declare a main function. Inside the main function,
    • Get the starting odometer reading from the user.
    • Call the function “MPG”.
    • Calculate the total MPG.
    • Display the result.
  • Call the main function.

Blurred answer
Students have asked these similar questions
Airline companies apply baggage restrictions for their passengers. An airline company has decided to apply a 10kg limitation for passengers' hand luggage and 20kg for their normal baggage. When passengers arrive, they enter their hand and normal luggage weight from the keyboard. If passengers exceed their normal baggage allowance of 10 dollars per gram, they pay 12 dollars per kg. Accordingly, write the program that calculates the baggage price of the airline they will go to according to the baggage values entered by the arriving passenger and keeps this from closing the program for each passenger. Note: If hand and normal baggage allowances are stretched below the maximum value, the payment amount will be considered not negative. An example printout is given on the right. Geri bildirim gönder
In Python Write a program that computes the fuel efficiency for a multi-leg journey. The program will first prompt for the starting odometer reading and then get information about a series of legs. For each leg, the user enters the current odometer reading and the amount of gas used (separated by a space). The user signals the end of the trip with a blank line. The program should print the miles per gallon achieved on each leg and the total MPG for the trip
Write a program that computes the fuel efficiency for a multi-leg journey. The program will first prompt for the starting odometer reading and then get information about a series of legs. For each leg, the user enters the current odometer reading and the amount of gas used (separated by a space). The user signals the end of the trip with a blank line. The program should print the miles per gallon achieved on each leg and the total MPG for the trip.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY