python输入十个学生成绩 统计最高分 ,最低分
时间: 2023-06-29 08:19:37 浏览: 1139
好的,我来帮你解决这个问题。下面是 Python 代码实现:
```python
scores = []
for i in range(10):
score = float(input("请输入第 %d 个学生的成绩:" % (i + 1)))
scores.append(score)
max_score = max(scores)
min_score = min(scores)
print("最高分为:%.2f,最低分为:%.2f" % (max_score, min_score))
```
以上代码首先创建一个空列表 `scores`,然后使用 `for` 循环输入 10 个学生的成绩,将每个成绩添加到 `scores` 列表中。最后使用 `max` 和 `min` 函数分别求出列表中的最高分和最低分,并将结果输出到控制台上。
希望我的回答能够帮助到你!
相关问题
写一个程序 在键盘上输入10个学生的成绩 统计最高分 最低分 和平均分
好的,这是一个基于 Python 语言的程序,可以实现你的需求:
```python
scores = []
for i in range(10):
score = int(input("请输入第%d个学生的成绩:" % (i+1)))
scores.append(score)
max_score = max(scores)
min_score = min(scores)
avg_score = sum(scores) / len(scores)
print("最高分为:", max_score)
print("最低分为:", min_score)
print("平均分为:", avg_score)
```
程序的实现很简单,首先定义一个空列表 scores,然后使用 for 循环输入 10 个学生的成绩,将成绩添加到 scores 列表中。接着使用内置函数 max、min 和 sum 计算最高分、最低分和平均分,最后输出结果即可。
python输入10位学生的考试成绩,统计并输出其中的最高分、最低分和平均分。
这是关于编程的问题,我可以为您提供答案。您可以使用Python的列表和循环来解决这个问题。以下是一个示例代码:
```python
scores = []
for i in range(10):
score = int(input("请输入第{}个学生的成绩:".format(i+1)))
scores.append(score)
max_score = max(scores)
min_score = min(scores)
avg_score = sum(scores) / len(scores)
print("最高分:", max_score)
print("最低分:", min_score)
print("平均分:", avg_score)
```
您只需输入10个学生的成绩,程序将自动计算最高分、最低分和平均分并输出。希望对您有帮助!
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)