设置学生成绩管理系统程序代码
时间: 2023-12-22 22:29:02 浏览: 52
根据提供的引用内容,以下是一个简单的学生成绩管理系统的程序代码示例:
```python
class Student:
def __init__(self, student_id, name, english1, english2, english3):
self.student_id = student_id
self.name = name
self.english1 = english1
self.english2 = english2
self.english3 = english3
class GradeManagementSystem:
def __init__(self):
self.students = []
def register_student(self, student_id, name, english1, english2, english3):
student = Student(student_id, name, english1, english2, english3)
self.students.append(student)
def modify_student_info(self, student_id, name, english1, english2, english3):
for student in self.students:
if student.student_id == student_id:
student.name = name
student.english1 = english1
student.english2 = english2
student.english3 = english3
break
def add_student(self, student_id, name, english1, english2, english3):
student = Student(student_id, name, english1, english2, english3)
self.students.append(student)
def delete_student(self, student_id):
for student in self.students:
if student.student_id == student_id:
self.students.remove(student)
break
def search_by_student_id(self, student_id):
for student in self.students:
if student.student_id == student_id:
return student
def search_by_class_subject(self, class_name, subject):
result = []
for student in self.students:
if student.class_name == class_name and student.subject == subject:
result.append(student)
return result
def search_by_class_subject_score_range(self, class_name, subject, min_score, max_score):
result = []
for student in self.students:
if student.class_name == class_name and student.subject == subject and min_score <= student.score <= max_score:
result.append(student)
return result
# 创建学生成绩管理系统对象
grade_management_system = GradeManagementSystem()
# 注册学生信息
grade_management_system.register_student("001", "张三", 80, 85, 90)
grade_management_system.register_student("002", "李四", 75, 90, 95)
# 修改学生信息
grade_management_system.modify_student_info("001", "张三", 85, 90, 95)
# 添加学生信息
grade_management_system.add_student("003", "王五", 70, 80, 85)
# 删除学生信息
grade_management_system.delete_student("002")
# 按学号查询学生成绩
student = grade_management_system.search_by_student_id("001")
print("学号:", student.student_id)
print("姓名:", student.name)
print("大学英语一成绩:", student.english1)
print("大学英语二成绩:", student.english2)
print("大学英语三成绩:", student.english3)
# 按班级、科目查询学生成绩
students = grade_management_system.search_by_class_subject("一班", "数学")
for student in students:
print("学号:", student.student_id)
print("姓名:", student.name)
print("数学成绩:", student.math)
# 按班级、科目及分数段查询学生成绩
students = grade_management_system.search_by_class_subject_score_range("一班", "数学", 60, 80)
for student in students:
print("学号:", student.student_id)
print("姓名:", student.name)
print("数学成绩:", student.math)
```
阅读全文