python学生成绩管理系统
时间: 2023-10-14 10:30:25 浏览: 85
python语言实现学生成绩管理系统
5星 · 资源好评率100%
好的,这是一个简单的Python学生成绩管理系统示例:
```python
students = {}
def add_student(name):
students[name] = {}
def add_score(name, subject, score):
students[name][subject] = score
def get_average(name):
scores = students[name].values()
average = sum(scores) / len(scores)
return average
def print_report():
for name, subjects in students.items():
print(f"{name}:")
for subject, score in subjects.items():
print(f"\t{subject}: {score}")
average = get_average(name)
print(f"\tAverage Score: {average}")
while True:
print("1. Add Student")
print("2. Add Score")
print("3. Print Report")
print("4. Quit")
choice = input("Enter Choice: ")
if choice == "1":
name = input("Enter Student Name: ")
add_student(name)
elif choice == "2":
name = input("Enter Student Name: ")
subject = input("Enter Subject: ")
score = int(input("Enter Score: "))
add_score(name, subject, score)
elif choice == "3":
print_report()
elif choice == "4":
break
else:
print("Invalid Choice")
```
这个系统使用字典来存储学生和他们的成绩。它提供了添加学生、添加成绩、打印报告和退出的选项。你可以根据自己的需要进行修改和扩展。
阅读全文