python学生管理系统

# 学生管理系统
"""
班级数据类型: list [student1, student2, student3]
学生的数据:  dict 
{
    name: mio,
    age :10,
    iphone: 100
}
"""
# 定义一个列表用来存放学生信息
student_class = []
def print_menu():
    print("---------------------------")
    print("      学生管理系统 V1.0")
    print(" 1:添加学生")
    print(" 2:删除学生")
    print(" 3:修改学生")
    print(" 4:查询学生")
    print(" 5:显示所有学生")
    print(" 6:退出系统")
    print("---------------------------")
def add_student():
    # 输入学生信息
    name = input("please input your name >>")
    age = int(input("please input your age >>"))
    iphone = int(input("please input your iphone >>"))
    # 判断学生是否存在
    for student in student_class:
        if student["name"] == name:
            print("学生已经存在!!")
            return None
    student = {
        "name" : name,
        "age" : age,
        "iphone" : iphone
    }
    student_class.append(student)
    print("插入成功!!")
    return None
def del_student():
    pos = int(input("please input your del student pos"))
    if pos >= len(student_class) or pos < 0:
        print("pos is error")
        return None
    sure = input("are your sure? yes or no >>>")
    if sure == "yes":
        del student_class[pos]
        print("删除成功")
    else:
        print("取消删除")
    return None
def modify_student():
    name = input("please input your want to modify student name >>>")
    # 寻找学生
    for student in student_class:
        if student["name"] == name:
            student["name"] = input("please input modify student name >>")
            student["age"] = input("please input modify student age >>")
            student["iphone"] = input("please input modify student iphone >>")
            print("修改成功!!!")
            return None
    print("您输入的学生不存在!!!!")
    return None
def find_student():
    name = input("please input your want to find student name >>>")
    for student in student_class:
        if student["name"] == name:
            print(student)
            return None
    print("没有找到学生")
def show_student():
    print(student_class)
def main():
    while True:
        print_menu()
        choose = int(input("请输入的您的选择>>>"))
        if choose == 1:
            add_student()
        elif choose == 2:
            del_student()
        elif choose == 3:
            modify_student()
        elif choose == 4:
            find_student()
        elif choose == 5:
            show_student()
        elif choose == 6:
            print("Bye~~")
            break
        else:
            print("input error")
    return None
main()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小徐的记事本

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值