可以录入学生信息,学员信息包括学号、姓名、3门课(语文、数学、英语)成绩。
时间: 2023-07-10 20:19:50 浏览: 63
好的,我可以帮您设计一个简单的学生信息管理系统。您需要在程序中定义一个学生类,包含学号、姓名和三门课程成绩的属性。然后,您可以使用列表或字典来存储所有学生的信息。以下是一个示例代码:
```python
class Student:
def __init__(self, stu_id, name, score):
self.stu_id = stu_id
self.name = name
self.score = score
students = [] # 存储所有学生信息的列表
# 添加学生信息
def add_student():
stu_id = input("请输入学号:")
name = input("请输入姓名:")
score = []
for i in range(3):
s = float(input("请输入{}课程成绩:".format(["语文", "数学", "英语"][i])))
score.append(s)
student = Student(stu_id, name, score)
students.append(student)
print("添加成功!")
# 查看学生信息
def show_students():
print("学号\t姓名\t语文\t数学\t英语")
for student in students:
print("{}\t{}\t{}\t{}\t{}".format(student.stu_id, student.name, student.score[0], student.score[1], student.score[2]))
# 主函数
def main():
while True:
print("请选择操作:")
print("1. 添加学生信息")
print("2. 查看学生信息")
print("3. 退出程序")
choice = input()
if choice == "1":
add_student()
elif choice == "2":
show_students()
elif choice == "3":
break
else:
print("无效的选择!")
if __name__ == '__main__':
main()
```
您可以根据您的需求进行修改和完善。
相关推荐
![text/x-c](https://img-home.csdnimg.cn/images/20210720083646.png)
![cpp](https://img-home.csdnimg.cn/images/20210720083646.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)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)