1
I’m trying to solve this problem in python:
Make a program that loads a list with the models of five cars (example of models: FUSCA, GOL, VECTRA etc). Upload another list with the consumption of these cars, that is, how many kilometers each of these cars makes with a liter of fuel.
Calculate and show:
- The most economical car model;
- How many liters of fuel each of the registered cars consumes to cover a distance of 1000 kilometers and how much this will cost, considering one that gasoline costs R $ 2,25 a liter.
Below follows an example screen. The layout of the information should be as close as possible to the example. The data is fictitious and can change with each execution of the program.
Comparison of Fuel Consumption
Veículo 1
Nome: fusca
Km por litro: 7
Veículo 2
Nome: gol
Km por litro: 10
Veículo 3
Nome: uno
Km por litro: 12.5
Veículo 4
Nome: Vectra
Km por litro: 9
Veículo 5
Nome: Peugeout
Km por litro: 14.5
Relatório Final
1 - fusca - 7.0 - 142.9 litros - R$ 321.43
2 - gol - 10.0 - 100.0 litros - R$ 225.00
3 - uno - 12.5 - 80.0 litros - R$ 180.00
4 - vectra - 9.0 - 111.1 litros - R$ 250.00
5 - peugeout - 14.5 - 69.0 litros - R$ 155.17
The lowest consumption is the peugeout.
Up here is how it should look. Follow my code below and what is missing to do. In this code I sent I’m just not sure how to find the lowest consumption value, to print the car. If anyone can help me thank you.
My code:
listaCarro = [None] * 5
listaConsumo = [None] * 5
listaDistancia = [None] * 5
listaCusto = [None] * 5
precoGasolina = 2.25
distancia = 1000
for i in range(0,5):
print ('Digite o nome {} carro: '.format(i+1))
listaCarro[i] = input()
for x in range(0,5):
print('Digite o consumo {} carro (km por litro): '.format(x+1))
listaConsumo[x] = float(input())
listaDistancia[x] = distancia / listaConsumo[x]
listaCusto[x] = listaDistancia[x] * precoGasolina
for j in range(0,5):
print('Veiculo {}'.format(j+1))
print('Nome: {}'.format(listaCarro[j]))
print('Km por litro: {}'.format(listaConsumo[j]))
for p in range(0,5):
print('{} - {} - {} - {} litros - R$ {}\n'.format(p+1, listaCarro[p], listaConsumo[p], round(listaDistancia[p],1), round(listaCusto[p],2)))