essence/essence.py

32 lines
591 B
Python
Raw Normal View History

2022-09-06 00:46:11 +02:00
#combien_de_donnees
ticket = int(input("Nombre de tickets a evaluer : "))
#plusieurs_donnees
2022-09-06 12:06:56 +02:00
j = 0
2022-09-06 00:46:11 +02:00
while (j < ticket) :
2022-09-06 12:06:56 +02:00
2022-09-06 00:46:11 +02:00
km = float(input("Distance parcourue (km) : "))
distance.append(km)
2022-09-06 12:06:56 +02:00
2022-09-06 00:46:11 +02:00
L = float(input("Quantite d'essence consommee (L) : "))
debit.append(L)
j = j + 1
2022-09-06 12:06:56 +02:00
2022-09-06 00:46:11 +02:00
2022-09-05 23:58:23 +02:00
#affichage_resultats
2022-09-06 00:46:11 +02:00
resultats = []
2022-09-05 23:58:23 +02:00
for i in range(len(distance)) :
2022-09-06 12:06:56 +02:00
calc = (debit[i]/distance[i])*100
2022-09-06 00:46:11 +02:00
#print(f"{calc:.3f} L/100km")
resultats.append(calc)
2022-09-06 12:06:56 +02:00
2022-09-06 00:46:11 +02:00
#moyenne
2022-09-06 00:58:21 +02:00
moyenne = sum(resultats)/len(resultats)
2022-09-06 00:46:11 +02:00
print(f"Moyenne : {moyenne:.3f} L/100km")