'''lecture_09_mpg.py Calculates and makes a decision about a car's MPG Oliver W. Layton Lecture 09 CS151: Computational Thinking: Visual Media Spring 2021 ''' def computeMPG(miles, gasUsed): '''Calculate miles-per-gallon, given miles traveled and gallons used''' mpg = miles / gasUsed # 300 / 10 = 30.0 return mpg def goodMileage(mpg): '''Report how good the gas mileage as miles-per-gallon is''' if mpg > 50: print(mpg, 'mpg is great gas mileage!') elif mpg >= 30: print(mpg, 'mpg is pretty good gas mileage.') elif mpg >= 20: print(mpg, 'mpg is acceptable.') else: print('The gas mileage is not great!') # main code # Calculate the MPG of our trip and determine how good it is miles = 300 tank = 10 myMPG = computeMPG(miles, tank) # myMPG = 30.0 goodMileage(myMPG) # goodMileage(30.0)