Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- lista = []
- with open('carros.csv', newline='') as csvfile:
- linha = csv.reader(csvfile, delimiter=',')
- for item in linha:
- lista.append(item)
- for i in range(len(lista)):
- for j in range(len(lista[i])):
- if lista[i][j].isnumeric():
- lista[i][j] = float(lista[i][j])
- somatotal = 0
- menormedia = 0
- index = -1
- for i in range(len(lista)):
- for j in range(len(lista[i])):
- if j > 0:
- if j == 3:
- somatotal += 10000 / (lista[i][j] / 10) * 3.98
- continue
- somatotal += lista[i][j]
- if i == 0:
- menormedia = somatotal
- if menormedia > somatotal:
- menormedia = somatotal
- index = i
- print(f"A média do {lista[i][0]} é {somatotal:.2f}")
- somatotal = 0
- print(f"A melhor média é do {lista[index][0]} gastando um total de {menormedia:.2f}")
- #ARQUIVOS
- Chevrolet Onix,36000,1400,118,1600
- Ford Fiesta,32000,1300,135,1800
- VW Fox,31000,1450,123,1800
- VW Polo,41000,1600,135,1500
- Hiunday HB20,40000,1200,116,1200
- Renault Sandero,30000,1300,128,1900
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement