2018-10-09 Python学生管理系统简易版
2018-10-09 本文已影响0人
楠木cral
(学生管理系统简易版)
用一个变量来保存一个班级的学生信息,学生信息包括:姓名、学号、成绩(英语、体育、美术、数学)、年龄
b.给这个班级添加学生
c.根据姓名查看班级里的某个学生的信息
d.根据姓名删除一个指定的学生信息
e.查看班级的所有的学生信息
f.求指定的学生平均成绩
students = [{'name': '小明', 'stu_id': 5120152566, 'age': 18, 'scores': {'英语': 96, '体育': 86, '美术': 84, '数学': 98}}]
while True:
print('****************************欢迎来到千锋学生管理系统*************************')
print('1 添加学生\n')
print('2 查询学生\n')
print('3 删除学生\n')
print('4 查看班级所有学生\n')
print('5 查询学生平均成绩\n')
print('0 退出系统\n')
print('*****************************************************************************')
num = int(input('请选择你的操作:'))
def tishi():
print('*********1.返回主页面**********')
print('*********0.退出系统************')
while True:
num2 = int(input("请选择操作:"))
if num2 == 1:
# import os
# os.system('clear')
return
if num2 == 0:
exit()
else:
print('********请正确操作!********')
def add_stu():
addname = input("请输入添加的学生姓名:")
addstu_id = input("请输入添加学生的学号:")
addage = input('请输入添加的学生年龄:')
addscore1 = int(input('请输入添加的学生英语成绩:'))
addscore2 = int(input('请输入添加的学生体育成绩:'))
addscore3 = int(input('请输入添加的学生美术成绩:'))
addscore4 = int(input('请输入添加的学生数学成绩:'))
students.append({'name': addname, 'stu_id': addstu_id, 'age': addage, 'scores': {'英语': addscore1, '体育': addscore2, '美术': addscore3, '数学': addscore4}})
print("添加成功!")
tishi()
def find_stu():
findname = str(input("请输入要查询的学生姓名:"))
for student in students:
if student['name'] == findname:
print("姓名:", student['name'])
print("学号:", student['stu_id'])
print("年龄:", student['age'])
print("英语成绩:", student['scores']['英语'])
print("体育成绩:", student['scores']['体育'])
print("美术成绩:", student['scores']['美术'])
print("数学成绩:", student['scores']['数学'])
break
tishi()
def del_stu():
delname = str(input("请输入要删除的学生姓名:"))
for student in students:
if student['name'] == delname:
students.remove(student)
print('删除成功!')
break
tishi()
def show_stu():
print("*姓名****学号****年龄***英语***体育***美术***数学*")
for student in students:
print(student['name'], '', student['stu_id'], '', student['age'], ' ', student['scores']['英语'], ' ', student['scores']['体育'], ' ', student['scores']['美术'], ' ', student['scores']['数学'])
tishi()
def score_stu():
stu_name = str(input("请输入要查询分数的学生姓名:"))
for student in students:
if student['name'] == stu_name:
averge_score = float((student['scores']['英语'] + student['scores']['体育'] + student['scores']['美术'] + student['scores']['数学']))/4
break
print('他的平均分为:',averge_score)
tishi()
if num == 0:
exit()
if num == 1:
add_stu()
# print(students)
if num == 2:
find_stu()
if num == 3:
del_stu()
# print(students)
if num == 4:
show_stu()
if num == 5:
score_stu()