fuel

py

School

University of Central Florida *

*We aren’t endorsed by this school

Course

2500C

Subject

Mechanical Engineering

Date

Feb 20, 2024

Type

py

Pages

1

Uploaded by UltraBuffaloPerson117

Report
# Fuel Efficiency # Consider the following problem: You are taking a road trip. # When you fill up your gas tank (you know how many gallons your tank is), # you notice the reading on your odometer. Later in the drive, # you see exactly how much gas is left and the reading on the odometer. # Given all of this information, we want to calculate how many more # miles we can drive before having to stop for gas again. # In real life, we would want to include a margin for error and stop # several miles short of when our fuel would run out. But for purposes # of simplicity, in this program, we'll simply calculate when we expect # to run out of fuel, assuming that we drive with a constant fuel efficiency. # Initial odometer reading start_odo = int(input("What is the initial odometer reading?\n")) # Size of the gas tank size_tank = int(input("What is the size of the gas tank?\n")) # Intermediate odometer reading odo = int(input("What is the current odometer reading?\n")) # Intermediate gas reading gas_left = float(input("How much gas is left?\n")) # How many miles have we driven? miles_driven = odo - start_odo gas_used = size_tank - gas_left # How many miles can we still go? mpg = miles_driven / gas_used distance = gas_left * mpg print("You can go", distance, "more miles!")
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help