L'exemple de code du chapitre 4 est le suivant.
--Point
sample04.py
scores = [60, 50, 60, 58, 54, 54,
58, 50, 52, 54, 48, 69,
34, 55, 51, 52, 44, 51,
69, 64, 66, 55, 52, 61,
46, 31, 57, 52, 44, 18,
41, 53, 55, 61, 51, 44]
length = len(scores)
for i in range(length):
print("Proposition de test#" + str(i),"But:",scores[i])
high_score = max(scores)
max_list = []
for i in range(length):
if scores[i] == high_score:
max_list.append(i)
print("Nombre total de tests:",length)
print("Le score le plus élevé:",max(scores))
print("Indice maximum:",max_list)
Recommended Posts