I'm trying to solve this problem in python:
Make a program that loads a list with the five car models (example of models: FUSCA, GOL, VECTRA etc). Charge another list with the consumption of these cars, that is, how many miles 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 it will cost, considering that the gasoline costs R $ 2.25 a liter.
Below is a sample screen. The provision of information should be as close as possible to the example. The data is fictitious and may change with each run 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 from peugeout.
Up here is how it should stay. Here's my code below and what's missing to do. In this code I sent only I'm not sure how to find the lowest value of the consumption, 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)))