fork download
  1. avgMiles = 0.0
  2. totGallons = 0.0
  3.  
  4. while True:
  5. miles = float(raw_input("Enter miles driven: "))
  6. gallons = float(raw_input("Enter gallons used: "))
  7.  
  8. print "MPG this trip:", miles / gallons
  9.  
  10. newTotGallons = totGallons + gallons
  11. avgMiles = avgMiles * totGallons / newTotGallons + miles / newTotGallons
  12. totGallons = newTotGallons
  13.  
  14. print "Total MPG:", avgMiles
  15.  
Runtime error #stdin #stdout #stderr 0.01s 7856KB
stdin
200
10
100
10
50
5
stdout
Enter miles driven: Enter gallons used: MPG this trip: 20.0
Total MPG: 20.0
Enter miles driven: Enter gallons used: MPG this trip: 10.0
Total MPG: 15.0
Enter miles driven: Enter gallons used: MPG this trip: 10.0
Total MPG: 14.0
Enter miles driven: 
stderr
Traceback (most recent call last):
  File "prog.py", line 5, in <module>
EOFError: EOF when reading a line