溫馨提示×

python如何求最高分和最低分

小億
971
2023-08-14 18:18:35
欄目: 編程語言

可以使用Python的內(nèi)置函數(shù)max()min()來求最高分和最低分。

假設(shè)有一個學生成績列表scores,可以使用以下代碼求最高分和最低分:

scores = [80, 90, 70, 85, 95]
highest_score = max(scores)
lowest_score = min(scores)
print("最高分:", highest_score)
print("最低分:", lowest_score)

輸出結(jié)果為:

最高分: 95
最低分: 70

這樣就可以求得列表中的最高分和最低分。

0