python学生成绩管理
时间: 2023-09-21 17:03:33 浏览: 111
好的,你需要一个学生成绩管理系统,可以使用 Python 来开发。以下是一个简单的学生成绩管理程序的示例代码:
```python
students = []
def add_student():
name = input("请输入学生姓名:")
math_score = int(input("请输入数学成绩:"))
english_score = int(input("请输入英语成绩:"))
student = {'name': name, 'math_score': math_score, 'english_score': english_score}
students.append(student)
print("添加成功!")
def remove_student():
name = input("请输入要删除的学生姓名:")
for student in students:
if student['name'] == name:
students.remove(student)
print("删除成功!")
return
print("未找到该学生!")
def search_student():
name = input("请输入要查找的学生姓名:")
for student in students:
if student['name'] == name:
print("姓名:{},数学成绩:{},英语成绩:{}".format(student['name'], student['math_score'], student['english_score']))
return
print("未找到该学生!")
def show_all_students():
if not students:
print("暂无学生信息!")
return
for student in students:
print("姓名:{},数学成绩:{},英语成绩:{}".format(student['name'], student['math_score'], student['english_score']))
while True:
print("1. 添加学生")
print("2. 删除学生")
print("3. 查找学生")
print("4. 显示所有学生")
print("5. 退出程序")
choice = int(input("请输入操作编号:"))
if choice == 1:
add_student()
elif choice == 2:
remove_student()
elif choice == 3:
search_student()
elif choice == 4:
show_all_students()
elif choice == 5:
break
else:
print("请输入正确的操作编号!")
```
这个程序可以让你添加、删除、查找和显示学生信息。你可以根据需要对其进行定制和扩展。
阅读全文