Sometimes, I want to quickly be able to convert miles per imperial gallon into kilometers per liter.

Create an application that will display the number of kilometers per liter (output) based on the number of miles per imperial gallon (input).

Make sure to round off the result to two decimal points. If the answer ends with a 0, it should be rounded off without the 0. So instead of 5.50, we should get 5.5.

Some useful associations relevant to this kata:
1 Imperial Gallon = 4.54609188 litres
1 Mile = 1.609344 kilometres

Difficulty: EASY
Starter code: def converter(mpg):
	

Solutions:
def converter(mpg):
	kpl = round(mpg * 1.609344 / 4.54609188, 2)
	return kpl


converter = lambda x: round(x * 0.354006043538, 2)


def converter(mpg):
	gallon_to_liter_rate = 4.54609188
	mile_to_km_rate = 1.609344
	return round(mpg * mile_to_km_rate / gallon_to_liter_rate, 2)


def converter(mpg):
	return round(mpg / 4.54609188 * 1.609344, 2) if mpg else 0


converter = lambda mpg, g=4.54609188, m=1.609344: round(mpg * (m / g), 2)


KM_PER_MILE = 1.609344
LITERS_PER_UK_GALLON = 4.54609188

def converter(mpg):
	return round(mpg * KM_PER_MILE / LITERS_PER_UK_GALLON, 2)


def converter(mpg):
	L_PER_G = 4.54609188
	KM_PER_MI = 1.609344
	return round(mpg * KM_PER_MI / L_PER_G, 2)


def converter(mpg):
	return round(mpg * 0.35400604353, 2)


converter = lambda mpg: round(mpg * 35.400604353) / 100


def converter(mpg: int) -> float:
	return round(mpg / (4.54609188 / 1.609344), 2)


def converter(mpg):
	x = 4.54609188
	y = 1.609344
	return round(mpg * y / x, 2)


def converter(mpg):
	c = mpg / 4.54609188 * 1.609344
	return round(c, 2)


def converter(mpg):
	km_new = round(mpg * 1.609344 / 4.54609188, 2)
	return km_new


def converter(mpg):
	lit = 4.54609188
	Km = mpg * 1.609344
	return round(Km / lit, 2)


def converter(mpg):
	(lr, km) = (1.609344, 4.54609188)
	return round(mpg * (lr / km), 2)


GALLON_LITRE_RATE = 4.54609188
MILE_KM_RATE = 1.609344

def converter(mpg):
	return round(mpg / GALLON_LITRE_RATE * MILE_KM_RATE, 2)


def converter(mpg):
	return round(0.3540061 * mpg, 2)


def converter(mpg):
	GALLON_IN_LITRES = 4.54609188
	MILE_IN_KM = 1.609344
	LITRES_PER_KM_SCALEFACTOR = GALLON_IN_LITRES / MILE_IN_KM
	return round(mpg / LITRES_PER_KM_SCALEFACTOR, 2)


def converter(mpg):
	litre = 4.54609188
	mile = 1.609344
	return round(mpg * mile / litre, 2)


def converter(mpg):
	ldReturn = mpg / 4.54609188
	ldReturn *= 1.609344
	return float('%.2f' % ldReturn)


def converter(mpg):
	mpk = 4.54609188 / 1.609344
	return round(mpg / mpk, 2)


def converter(mpg):
	kpl = 1.609344 / 4.54609188 * mpg
	r = round(kpl, 2)
	if type(r) is int:
		return int(r)
	elif type(r * 10) is int:
		return round(r, 1)
	else:
		return r


def converter(mpg):
	return round(mpg * 0.354006043, 2)


def converter(mpg):
	res = mpg / 4.54609188 * 1.609344
	temp = f'{res:.2f}'
	if temp[-1] == '0':
		temp = f'{res:.1f}'
	erg = float(temp)
	return erg


def converter(mpg):
	km_in_mile = 1.609344
	litres_in_gallon = 4.54609188
	return round(mpg * km_in_mile / litres_in_gallon, 2)


import numpy as np

def converter(mpg):
	return np.round(mpg * 0.354006, 2)


def converter(mpg):
	miles_to_km = 1.609344
	gallon_to_liter = 4.54609188
	return round(mpg / gallon_to_liter * miles_to_km, 2)


def converter(mpg):
	k = 1.609344 / 4.54609188
	return round(k * mpg, 2)


def converter(mpg):
	conver = 1.609344 / 4.54609188
	return round(mpg * conver, 2)


def converter(mpg):
	ans = mpg * 1.609344 / 4.54609188
	return round(ans, 2)


def converter(mpg):
	Imperial_Gallon = 4.54609188
	Mile = 1.609344
	kml = Mile / Imperial_Gallon
	return round(kml * mpg, 2)


def converter(mpg):
	gallon = 4.54609188
	miles = 1.609344
	return round(mpg * miles / gallon, 2)


imperial_gallon = 4.54609188
mile = 1.609344

def converter(mpg):
	return round(mpg / imperial_gallon * mile, 2)


converter = lambda n: round(n * 1.609344 / 4.54609188, 2)


def converter(mpg):
	print(4.54609188 / 1.609344)
	return round(mpg / 2.8248105314960625, 2)


def converter(mpg):
	mile = 1.609344
	gallon = 4.54609188
	kpl = mpg * mile / gallon
	return round(kpl, 2)


def converter(mpg):
	answer = mpg / 2.82481053
	return round(answer, 2)


def converter(mpg):
	klm = mpg * 1.609344 / 4.54609188
	return round(klm, 2)


R = 4.54609188 / 1.609344

def converter(mpg):
	return round(mpg / R, 2)


def converter(mpg):
	kml = mpg * 1.609344 / 4.54609188
	return round(kml, 2)


def converter(mpg):
	miles_to_km = 1.609344
	gallon_to_litre = 4.54609188
	return round(mpg * miles_to_km / gallon_to_litre, 2)


def converter(mpg):
	Lpg = 4.54609188
	Kpm = 1.609344
	return round(mpg * Kpm / Lpg, 2)


def converter(mpg):
	kmpg = mpg * 1.609344
	kmpl = kmpg / 4.54609188
	return float(format(kmpl, '.2f'))


def converter(mpg):
	l = 4.54609188
	k = 1.609344
	kpl = k / l * mpg
	return round(kpl, 2)


def converter(mpg):
	result = '{:.2f}'.format(mpg * 1.609344 / 4.54609188)
	return float(result) if result[-1] != '0' else float(result[:-1])


def converter(mpg):
	kpl = mpg * 1.609344 / 4.54609188
	kpl = round(kpl * 100) / 100
	return kpl


def converter(mpg):
	return float('{:.2f}'.format(mpg / (4.54609188 / 1.609344)))


def converter(mpg):
	KM_PER_MILE = 1.609344
	LITRE_PER_GALLON = 4.54609188
	tmp = round(mpg * KM_PER_MILE / LITRE_PER_GALLON, 2) * 100
	return tmp // 10 / 10 if tmp % 10 == 0 else tmp / 100


def converter(mpg):
	m = 1.609344
	g = 4.54609188
	res_round = round(mpg * m / g, 2)
	return res_round


def converter(mpg):
	gln = 4.54609188
	ml = 1.609344
	return round(mpg * ml / gln, 2)


def converter(mpg):
	litres = 4.54609188
	km = 1.609344
	kpl = km / litres * mpg
	return round(kpl, 2)


def converter(mpg):
	return round(mpg / 2.82481, 2)


def converter(m):
	return round(m * 0.354006044, 2)


converter = lambda mpg: round(mpg * 0.354006043538, 2)


def converter(mpg):
	gallit = 1.609344 / 4.54609188
	lit = round(mpg * gallit, 2)
	return lit


def converter(mpg):
	x = round(mpg * 1.609344 / 4.54609188, 2)
	return x if str(x)[-1] != '0' else float(str(x)[:-1])


def converter(mpg):
	kmpl = mpg * 1.609344 * (1 / 4.54609188)
	return round(kmpl, 2)


def converter(mpg):
	liter_per_mile = 1.609344 / 4.54609188
	return round(liter_per_mile * mpg, 2)


def converter(mpg):
	km = 1.609344
	liters = 4.54609188
	return round(mpg / liters * km, 2)


def converter(mpg):
	return round(mpg / 2.8248105, 2)


def converter(mpg):
	M = 1.609344
	g = 4.54609188
	kpg = mpg * M / g
	return round(kpg, 2)


def converter(mpg):
	conv = 1.609344 / 4.54609188
	return round(mpg * conv, 2)


def converter(mpg):
	(t1, t2) = (4.54609188, 1.609344)
	return round(mpg * t2 / t1, 2)


import math

def converter(mpg):
	res = mpg * 0.354006
	s = str(res)
	dot = s.index('.')
	if [len(s) - 1] == '0':
		return float(s[:dot + 1])
	else:
		return round(res, 2)


def converter(mpg):
	kilo = round(mpg * 1.609344 / 4.54609188, 2)
	return kilo


def converter(mpg):
	coef = 4.54609188 / 1.609344
	return round(mpg / coef, 2)


def converter(mpg):
	a = mpg * 1.609344 / 4.54609188
	return round(a, 2)


def converter(mpg):
	kml = mpg * 1.609344 / 4.54609188
	return float('%.2f' % round(kml, 2))


def converter(mpg):
	return round(mpg / 2.824810531, 2)


def converter(x):
	return round(x / (4.54609188 / 1.609344), 2)


def converter(mpg):
	kl = round(mpg * 1.609344 / 4.54609188, 2)
	return kl


def converter(mpg):
	imperial_gallon_in_litres = 4.54609188
	mile_in_km = 1.609344
	lpk = mpg * mile_in_km / imperial_gallon_in_litres
	return float('{0:.2f}'.format(lpk))


def converter(mpg):
	conversionFactor = 1.609344 / 4.54609188
	return round(mpg * conversionFactor, 2)


converter = lambda mpg: round(0.354006 * mpg, 2)


def converter(mpg):
	kpl = mpg / 2.824810531496063
	return float('{:.2f}'.format(kpl))


def converter(mpg):
	ans = mpg / 2.824810531496063
	return float('{:.2f}'.format(ans))


import math

def converter(mpg):
	return round(mpg / (4.54609188 / 1.609344), 2)


MILE = 1.609344
GALLON = 4.54609188

def converter(mpg):
	return round(mpg / GALLON * MILE, 2)


def converter(mpg):
	ig = 4.54609188
	M = 1.609344
	return round(mpg * M / ig, 2)


IMP_GALLON_IN_LITRES = 4.54609188
MILE_IN_KMS = 1.609344

def converter(mpg):
	return round(mpg / IMP_GALLON_IN_LITRES * MILE_IN_KMS, 2)


def converter(mpg):
	converted_value = mpg * 1.609344 / 4.54609188
	return round(converted_value, 2)


import decimal

def converter(mpg):
	mpg = decimal.Decimal(mpg)
	m2km = decimal.Decimal(1.609344)
	g2l = decimal.Decimal(4.54609188)
	r = mpg * m2km / g2l
	return float(r.quantize(decimal.Decimal('1.00')).normalize())


def converter(mpg):
	mile_to_kilometre = 1.609344
	gallon_to_litre = 4.54609188
	formula = mpg * (mile_to_kilometre / gallon_to_litre)
	result = round(formula, 2)
	return result


def converter(mpg):
	lpg = 4.54609188
	kpm = 1.609344
	n = mpg * kpm / lpg
	return float(str('{:.2f}'.format(n)).rstrip('0'))