You've just returned from a road trip and are curious about your car's fuel consumption during the trip. Unfortunately, you didn't reset the counte...
For further actions, you may consider blocking this person and/or reporting abuse
Ruby:
typescript
Haskell
Playground
Hosted on Repl.it.
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 = []
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()
Extra credit: Convert from
l/100km
to SI units and visualize the resulting quantity.So like in Kg? I'm not sure I understood the principle behind the SI units. Could you bring some light to it?
what-if.xkcd.com/11/