re: Daily Challenge #106 - Average Fuel Consumption VIEW POST

FULL DISCUSSION
 

the code is self-explanatory

def avg_fuel_consumption(before, after):
avg_bef = before[0] * (before[1] / 100)
avg_aft = after[0] * (after[1] / 100)
avg_current = avg_aft - avg_bef
print("The average fuel consumption during hte trip is :", avg_current)

def worker_method():
before = []
after = []

before.append(float(input("Enter the average consumption before trip: ")))
before.append(int(input("Enter the distance travelled  before trip: ")))
after.append(float(input("Enter the average consumption after trip: ")))
after.append(int(input("Enter the distance travelled  after trip: ")))

return (avg_fuel_consumption(before,after))

if name == 'main':
worker_method()
while True:
answer = input("Would you like to try again? Y/N: ").lower()
if answer == 'y':
worker_method()
elif answer == 'n':
break
else:
answer = raw_input('Incorrect option. Type "YES" to try again or "NO" to leave": ').lower()

code of conduct - report abuse