可以使用Python的内置函数max()和min()来求最高分和最低分。
假设有一个学生成绩列表scores,可以使用以下代码求最高分和最低分:
scores = [80, 90, 70, 85, 95]
highest_score = max(scores)
lowest_score = min(scores)
print("最高分:", highest_score)
print("最低分:", lowest_score)
输出结果为:
最高分: 95
最低分: 70
这样就可以求得列表中的最高分和最低分。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: Python中代码文档编写技巧有哪些