# conversioni

# 1 miglio = 1609.344 metri
# 1 gallone = 3.785411784 litri


def liters_100km_to_miles_gallon(litres):
    """converte l/100km in miglia per gallone"""
    if litres < 0:
        return None

    gallons_k = litres / 3.785411784 # per 100 km

    gallons_m = gallons_k / 100 # per 1 km

    gallons_m = gallons_m * 1.609344 # per 1 mi

    gallons = gallons_m ** (-1)

    return gallons

def miles_gallon_to_liters_100km(miles):
    """converte miglia per gallone in l/100km"""

    chilometers = miles * 1.609344 # con un gallone

    chilometers_l = chilometers / 3.785411784 # con un litro

    chilometers_100 = chilometers_l / 100 # 100 km per L

    liters_100 = chilometers_100 ** (-1)

    return liters_100

print(liters_100km_to_miles_gallon(3.9))
print(liters_100km_to_miles_gallon(7.5))
print(liters_100km_to_miles_gallon(10.))
print(miles_gallon_to_liters_100km(60.3))
print(miles_gallon_to_liters_100km(31.4))
print(miles_gallon_to_liters_100km(23.5))

