学生管理系统简易版
mian
import view
import function
def main():
students = []
students.append({"name": '0',"studenId": 0,"age": 0,"englishGrades": 60,"sportsGrades": 80,"artGrades": 70,"mathGrades": 90})
students.append({"name": '1', "studenId": 0, "age": 0, "englishGrades": 80, "sportsGrades": 70, "artGrades": 65, "mathGrades": 80})
while True:
view.mianView()
option = input("请输入操作数:")
if option == '1':
function.increaseStudent(students)
elif option == '2':
function.findStudent(students)
elif option == '3':
function.deleteStudent(students)
elif option == '4':
function.findAverageGrades(students)
elif option == 'q':
break
else:
print("输入操作数有误!!!")
if __name__ == "__main__":
main()
function
import view
import os
def increaseStudent(students):
student = {"name": 0,"studenId": 0,"age": 0,"englishGrades": 0,"sportsGrades": 0,"artGrades": 0,"mathGrades": 0}
student["name"] = input("请输入新同学的姓名:")
student["studenId"] = input("请输入新同学的学号:")
student["age"] = input("请输入新同学的年龄:")
student["englishGrades"] = input("请输入新同学的英语成绩:")
student["sportsGrades"] = input("请输入新同学的体育成绩:")
student["artGrades"] = input("请输入新同学的美术成绩:")
student["mathGrades"] = input("请输入新同学的数学成绩:")
students.append(student)
view.increaseStudentFinishView()
while True:
option = input("请输入操作数:")
if option == '1':
increaseStudent(students)
elif option == '2':
return True
else:
print("输入操作数有误!!!")
def findStudent(students):
view.findStudentView()
while True:
option = input("请输入操作数:")
if option == '1':
findAllstudent(students)
view.findStudentView()
elif option == '2':
findNamestudent(students)
view.findStudentView()
elif option == '3':
return True
else:
print("输入操作数有误!!!")
def findAllstudent(students):
print("**以下是所有学生信息:")
num = 0
while num < len(students):
print(num,students[num])
num += 1
print("**1.返回上一层")
while True:
option = input("请输入操作数:")
if option == '1':
return True
else:
print("输入操作数有误!!!")
def findNamestudent(students):
while True:
name = input("**请输入要查找的学生姓名:")
flag = 0
for tempname in students:
if name == tempname['name']:
flag = 1
print(name,"的信息是",tempname)
if flag:
print("**1.返回上一层")
while True:
option = input("请输入操作数:")
if option == '1':
return True
else:
print("输入操作数有误!!!")
else:
print("姓名有误!!!")
def deleteStudent(students):
print("**以下是所有学生信息:")
num = 0
while num < len(students):
print(num, students[num])
num += 1
while True:
option = int(input("请输入需删除学生的序号:"))
if option < len(students):
students.pop(option)
view.deleteStudentFinishView()
while True:
option = input("请输入操作数:")
if option == '1':
deleteStudent(students)
return True
elif option == '2':
return True
else:
print("输入操作数有误!!!")
else:
print("输入操作数有误!!!")
pass
def findAverageGrades(students):
while True:
name = input("**请输入要查找的学生姓名:")
flag = 0
for tempname in students:
if name == tempname['name']:
flag = 1
AverageGrades = (int(tempname["englishGrades"]) + int(tempname["sportsGrades"]) + int(tempname["artGrades"]) + int(tempname["mathGrades"])) / 4
print(name,"的平均成绩是",AverageGrades)
if flag:
print("**1.返回上一层")
while True:
option = input("请输入操作数:")
if option == '1':
return True
else:
print("输入操作数有误!!!")
else:
print("姓名有误!!!")
view
def mianView():
print("*****************************************")
print("*欢迎进入小野猪学校学生管理系统: *")
print("*1.添加学生 *")
print("*2.查找学生 *")
print("*3.删除学生 *")
print("*4.查指定学生的平均成绩 *")
print("*q.退出系统 *")
print("*****************************************")
def increaseStudentFinishView():
print("*****************************************")
print("*添加成功!! *")
print("* *")
print("*1.继续添加 *")
print("*2.返回上一层 *")
print("*****************************************")
def findStudentView():
print("*****************************************")
print("*1.查看所有学生信息 *")
print("*2.根据名字查看学生信息 *")
print("*3.返回上一层 *")
print("*****************************************")
def deleteStudentFinishView():
print("*****************************************")
print("*删除成功!! *")
print("* *")
print("*1.继续删除 *")
print("*2.返回上一层 *")
print("*****************************************")