学生成绩管理系统数组
时间: 2023-12-22 20:28:07 浏览: 37
以下是一个简单的学生成绩管理系统的数组实现:
```python
# 初始化学生信息
students = [
{'name': '张三', 'score': [90, 80, 85]},
{'name': '李四', 'score': [85, 75, 90]},
{'name': '王五', 'score': [80, 90, 95]}
]
# 添加学生信息
def add_student(name, score):
students.append({'name': name, 'score': score})
# 删除学生信息
def remove_student(name):
for student in students:
if student['name'] == name:
students.remove(student)
# 修改学生信息
def modify_student(name, score):
for student in students:
if student['name'] == name:
student['score'] = score
# 查询学生信息
def query_student(name):
for student in students:
if student['name'] == name:
return student
# 计算学生平均分
def calculate_average_score(name):
student = query_student(name)
if student:
return sum(student['score']) / len(student['score'])
else:
return None
```
以上代码实现了一个简单的学生成绩管理系统,其中使用了一个包含学生信息的数组。可以通过调用不同的函数来实现添加、删除、修改、查询学生信息以及计算学生平均分等功能。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.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)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)