请帮我用python语言编写一个完整的学生成绩管理系统,学生成绩信息包括:学期、学号、班别、姓名、四门课程成绩(语文、数学、英语和 Python),具体实现以下七个功能: (1)创建信息并以磁盘文件保存; (2)读取磁盘文件并显示输出所有学生的成绩; (3)能按学期、按班级完成对学生成绩的录入、修改; (4)能按班级统计学生的成绩,求学生的总分及平均分; (5)能查询学生成绩,不及格科目及学生名单; (6)能按班级输出学生的成绩单; (7)显示输出 60分以下、60-79、 80-89、90分以上各分数段的学生信息。
时间: 2023-02-09 14:07:36 浏览: 189
下面是完整的学生成绩管理系统的 Python 代码:
```python
import csv
# 学生成绩类
class Student:
def __init__(self, term, student_id, class_name, name, chinese, math, english, python):
self.term = term
self.student_id = student_id
self.class_name = class_name
self.name = name
self.chinese = chinese
self.math = math
self.english = english
self.python = python
self.total_score = chinese + math + english + python
self.average_score = self.total_score / 4
# 创建信息并以磁盘文件保存
def create_info_and_save(students):
with open('student_info.csv', 'w', newline='') as csvfile:
fieldnames = ['term', 'student_id', 'class_name', 'name', 'chinese', 'math', 'english', 'python']
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writeheader()
for student in students:
writer.writerow({
'term': student.term,
'student_id': student.student_id,
'class_name': student.class_name,
'name': student.name,
'chinese': student.chinese,
'math': student.math,
'english': student.english,
'python': student.python
})
# 读取磁盘文件并显示输出所有学生的成绩
def read_info_and_display():
students = []
with open('student_info.csv', newline='') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
term = row['term']
student_id = row['student_id']
class_name = row['class_name']
name = row['name']
chinese = int(row['chinese'])
math = int(row['math'])
english = int(row['english'])
python = int(row['python'])
students.append(Student(term, student_id, class_name, name, chinese, math, english, python))
for student in students:
print(f'{student.term}, {student.student_id}, {student.class_name}, {student.name}, {student.chinese}, {student.math}, {student.english}, {student.python}, {student.total_score}, {student.average_score}')
# 按学期、按班级完成对学生成绩的录入、修改
def update_info(students):
term =
阅读全文