Hi,

I just wanted to check to see if I did this right. My answer seems OK… it’s not exactly the same as what the book says I should get. I seem to get 7.78 for (100,30) and 11.67 for (150,30. Any suggestions/comments are appreciated… thanks! Here is my code:

7 #Exercise #7 8 9 def convert_mileage(mpg): 10 liter_per_gallon = 3.7 11 kilometer_per_mile = 1.6 12 return (100 * liter_per_gallon) / (kilometer_per_mile * mpg) 13 14 #print convert_mileage(20) 15 16 #Exercise 9 17 18 def liters_needed(distance, gas): 19 distance = distance * 0.6 20 gas = convert_mileage(gas) 21 return distance/gas 22 23 print liters_needed(150,30)