学生成绩管理系统python查找
时间: 2023-12-25 08:29:59 浏览: 79
以下是一个简单的学生成绩管理系统的Python代码示例,可以实现查找学生信息的功能:
```python
class Student:
def __init__(self, name, score):
self.name = name
self.score = score
class ScoreManagementSystem:
def __init__(self):
self.students = []
def add_student(self, name, score):
student = Student(name, score)
self.students.append(student)
def search_student(self, name):
for student in self.students:
if student.name == name:
return student
return None
# 创建学生成绩管理系统对象
sms = ScoreManagementSystem()
# 添加学生信息
sms.add_student("Alice", 90)
sms.add_student("Bob", 80)
sms.add_student("Charlie", 70)
# 查找学生信息
student = sms.search_student("Bob")
if student:
print("学生姓名:", student.name)
print("学生成绩:", student.score)
else:
print("未找到该学生信息")
```
运行以上代码,将输出:
```
学生姓名: Bob
学生成绩: 80
```
阅读全文