1. 建立学生信息,每个学生的信息应包括:学号、姓名、性别、班级、至少3门课程的成绩; 2. 数据输入:输入学生的各项信息; 3. 数据修改:根据输入学生的学号可以选择修改该学生的信息; 4. 数据处理:可以选择处理方式为:排序、查询。其中: a) 排序:按学号排序 b) 查询:根据学号查询成绩 5. 数据输出:输出学生的相应结果信息; 6. 退出:退出整个学生信息管理系统。 7. 输出结果截屏的第一条记录一定要反映出你自己的真实信息。
时间: 2024-03-20 18:43:04 浏览: 34
好的,这是一个较为复杂的程序,需要比较长的代码实现。以下是一个简化版的示例程序,可以实现部分功能,供参考:
```python
class Student:
def __init__(self, id, name, gender, cls, scores):
self.id = id
self.name = name
self.gender = gender
self.cls = cls
self.scores = scores
class StudentManager:
def __init__(self):
self.students = []
def add_student(self, student):
self.students.append(student)
def find_student_by_id(self, id):
for student in self.students:
if student.id == id:
return student
return None
def modify_student_by_id(self, id, name, gender, cls, scores):
student = self.find_student_by_id(id)
if student:
student.name = name
student.gender = gender
student.cls = cls
student.scores = scores
def sort_students_by_id(self):
self.students.sort(key=lambda student: student.id)
def find_scores_by_id(self, id):
student = self.find_student_by_id(id)
if student:
return student.scores
else:
return None
if __name__ == '__main__':
manager = StudentManager()
while True:
print('请选择操作:')
print('1. 添加学生信息')
print('2. 修改学生信息')
print('3. 排序')
print('4. 查询成绩')
print('5. 退出')
choice = input()
if choice == '1':
print('请输入学号:')
id = input()
print('请输入姓名:')
name = input()
print('请输入性别:')
gender = input()
print('请输入班级:')
cls = input()
print('请输入成绩(用逗号分隔):')
scores = input().split(',')
scores = [float(score) for score in scores]
student = Student(id, name, gender, cls, scores)
manager.add_student(student)
print('添加成功!')
elif choice == '2':
print('请输入学号:')
id = input()
print('请输入姓名:')
name = input()
print('请输入性别:')
gender = input()
print('请输入班级:')
cls = input()
print('请输入成绩(用逗号分隔):')
scores = input().split(',')
scores = [float(score) for score in scores]
manager.modify_student_by_id(id, name, gender, cls, scores)
print('修改成功!')
elif choice == '3':
manager.sort_students_by_id()
print('排序成功!')
elif choice == '4':
print('请输入学号:')
id = input()
scores = manager.find_scores_by_id(id)
if scores:
print(f'学号为{id}的学生成绩为:{scores}')
else:
print(f'学号为{id}的学生不存在!')
elif choice == '5':
print('再见!')
break
else:
print('无效的选择!')
```
这个程序实现了学生信息的添加、修改、排序和查询成绩的功能,但是没有实现持久化存储和界面化操作,需要进一步完善。另外,这个程序中并没有输出结果截屏的需求,因此需要根据实际情况进行修改。
相关推荐
![cpp](https://img-home.csdnimg.cn/images/20210720083646.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.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)
![text/x-c](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)