日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

python學(xué)生管理系統(tǒng)

系統(tǒng) 1689 0
            student = []


def print_menu():
    print("學(xué)生管理系統(tǒng)V2.0")
    print("=" * 30)
    print("1.添加學(xué)生基本信息")
    print("2.通過學(xué)號刪除學(xué)生信息")
    print("3.顯示全部學(xué)生信息")
    print("4.通過姓名查找學(xué)生的信息")
    print("5.通過學(xué)號修改學(xué)生信息")
    print("6.導(dǎo)出學(xué)生基本信息到指定路徑的文件中")
    print("7.查詢成績最高的學(xué)生基本信息")
    print("8.查詢成績最低的學(xué)生基本信息")
    print("9.根據(jù)學(xué)生綜合成績排序后顯示基本信息")
    print("10.根據(jù)輸入的綜合成績,統(tǒng)計大于輸入成績的人數(shù)")
    print("11.計算當(dāng)前所有學(xué)生綜合成績的平均值")
    print("12.退出系統(tǒng)")
    print("=" * 30)

def add():
    xh = input("請輸入學(xué)生的學(xué)號:")
    xm = input("請輸入學(xué)生姓名:")
    xb = input("請輸入學(xué)生性別:(男/女)")
    phone = input("請輸入學(xué)生的手機號碼:")
    score = input("請輸入學(xué)生的綜合成績:")
    student_infos = {}
    student_infos["xuehao"] = xh
    student_infos["name"] = xm
    student_infos["sex"] = xb
    student_infos["phone"] = phone
    student_infos["score"] = score
    student.append(student_infos)
    print(student)





def del_info():
    stdId =input("請輸入需要刪除學(xué)生的學(xué)號:")
    z = 0
    for temp in student:
            if stdId == temp['xuehao']:
                    indexxuehao = student.index(temp)
                    z = 1
                    break
            else:
                    continue
    if z ==1:
            fina = input ("確認是否刪除?(yes or no):")
            if fina == "yes":
                del student[indexxuehao]
                print("恭喜您已成功刪除該新學(xué)生了!")
            else:
                print("您放棄刪除該學(xué)生信息了!")
    else:
            print("很抱歉,系統(tǒng)不存在該學(xué)生信息!")

def display():
    print("*" * 30)
    print("學(xué)生的信息如下:")
    print("*" * 30)
    print("序號    學(xué)號    姓名    性別   手機號碼    綜合成績")
    i = 1
    for temp in student:
        print("%d      %s      %s      %s     %s      %s" % (
            i, temp["xuehao"], temp["name"], temp["sex"], temp["phone"], temp["score"]))
        i += 1






def find():
    while True:
        name = input("請輸入要查找的學(xué)生姓名")
        for temp in student:
            if temp['name'] == name:
                print("找到此學(xué)生,信息如下:")
                print("學(xué)號:%s  姓名:%s  性別:%s  手機號碼:%s  綜合成績:%s  " % (
                    temp["xuehao"], temp["name"], temp["sex"], temp["phone"], temp["score"]))
                break
            else:
                print("沒有這個學(xué)生")

def change():
    print("您選擇了修改學(xué)生信息功能")
    gai = input("請輸入你要修改學(xué)生的學(xué)號:")
    i = 0
    ii = 0
    for temp in student:
        if temp["xuehao"] == gai:
            ii = 1
            break
        else:
            i = i + 1
    if ii == 1:
        while True:
            xiaocaidan = int(input(" 1.修改學(xué)號\n 2.修改姓名 \n 3.修改性別 \n 4.修改手機號碼 \n 5.修改綜合成績 \n 6.退出修改 \n"))
            if xiaocaidan == 1:
                aaa = input("輸入更改后的學(xué)號:")
                # 修改后的學(xué)號要驗證是否唯一
                i = 0
                ii1 = 0
                for temp1 in student:
                    if temp1["xuehao"] == aaa:
                        ii1 = 1
                        break
                    else:
                        i = i + 1
                if ii1 == 1:
                    print("輸入學(xué)號不可重復(fù),修改失敗!")
                else:
                    temp["xuehao"] = aaa
                    print("學(xué)號已修改")
            elif xiaocaidan == 2:
                bbb = input("輸入新的姓名:")
                temp["name"] = bbb
                print("姓名已修改")
            elif xiaocaidan == 3:
                ccc = input("輸入新的性別(男/女):")
                temp["sex"] = ccc
                print("性別已修改")
            elif xiaocaidan == 4:
                ddd = input("輸入新的手機號碼:")
                temp["phone"] = ddd
                print("手機號碼已修改")
            elif xiaocaidan == 5:
                eee = input("輸入新的成績:")
                temp["score"] = eee
                print("綜合成績已修改")
            elif xiaocaidan == 6:
                break
            else:
                print("輸入錯誤請重新輸入")
    else:
        print("學(xué)號輸入錯誤,修改失敗!")


def baocun():
    file = open("xueshengxinxi.txt", "w")
    file.write(str(student))
    file.write('\n')
    file.close()


def findmax():
    studentone = []
    for temp in student:  # 遍歷字典的成績
        studentone.append(temp["score"])  # 將遍歷的成績加入空列表
        studentone.sort(reverse=True)  # 將列表的值從大到小排序
        n = studentone[0]
    i = 0
    j = 0
    for temp in student:
        if temp["score"] == n:
            j = 1
            break
        else:
            i = i + 1
    if j == 0:
        print("沒有此學(xué)生,查詢失敗!")
    else:
        print("找到此學(xué)生,信息如下:")
        print("學(xué)號:%s  姓名:%s  性別:%s  手機號碼:%s  綜合成績:%s" % (
            temp["xuehao"], temp["name"], temp["sex"], temp["phone"], temp["score"]))


def findmin():
    studenttwo = []
    for temp in student:  # 遍歷字典的成績
        studenttwo.append(temp["score"])  # 將遍歷的成績加入空列表
        studenttwo.sort()  # 將列表的值從小到大排序
        n = studenttwo[0]
    i = 0
    j = 0
    for temp in student:
        if temp["score"] == n:
            j = 1
            break
        else:
            i = i + 1
    if j == 0:
        print("沒有此學(xué)生,查詢失敗!")
    else:
        print("找到此學(xué)生,信息如下:")
        print("學(xué)號:%s  姓名:%s  性別:%s  手機號碼:%s  綜合成績:%s  " % (
            temp["xuehao"], temp["name"], temp["sex"], temp["phone"], temp["score"]))


def paixu():
    print("從高到低成績排序:")
    print("序號    學(xué)號    姓名    性別   手機號碼    綜合成績")
    studentthree = []
    for temp in student:  # 遍歷字典的成績
        studentthree.append(temp["score"])  # 將遍歷的成績加入空列表
        studentthree.sort(reverse=True)  # 將列表的值從大到小排序
    for n in studentthree:
        i = 0
        j = 0
        for temp in student:
            if temp["score"] == n:
                j = 1
                break
            else:
                i = i + 1
        if j == 0:
            print("沒有此學(xué)生,查詢失敗!")
        else:
            print("%d      %s      %s      %s     %s      %s" % (
                i, temp["xuehao"], temp["name"], temp["sex"], temp["phone"], temp["score"]))


def count():
    studentfour = []
    studentfive = []
    for temp in student:  # 遍歷字典的成績
        studentfour.append(temp["score"])  # 將遍歷的成績加入空列表
    a = input("請輸入需要統(tǒng)計人數(shù)的成績線(大于該成績的人數(shù)):")
    i = 0
    for temp in studentfour:
        if temp[i] >= a:
            studentfive.append(temp[i])
        else:
            pass
        i += 1
    print("大于該成績的人數(shù)有:%s" % (len(studentfive)))


def average():
    studentsix = []
    for temp in student:  # 遍歷字典的成績
        studentsix.append(temp["score"])  # 將遍歷的成績加入空列表
        studentsix = [int(x) for x in studentsix]
        tt = sum(studentsix)
        pingjun = tt / len(studentsix)
        print(pingjun)


def quit():
    while True:
        d = input("確定退出嗎?(Yes or No):")
        if d == "Yes":
            break
        else:
            print("輸入有誤,請重新輸入")


def last():
    while True:
        print_menu()
        key = input("請輸入功能對應(yīng)的數(shù)字:")
        if key == "1":
            add()
        elif key == "2":
            del_info()
        elif key == "3":
            display()
        elif key == "4":
            find()
        elif key == "5":
            change()
        elif key == "6":
            baocun()
        elif key == "7":
            findmax()
        elif key == "8":
            findmin()
        elif key == "9":
            paixu()
        elif key == "10":
            count()
        elif key == "11":
            average()
        elif key == "12":
            quit()

last()


          

更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 凯里市| 南投市| 巴塘县| 永仁县| 福安市| 浦北县| 洛浦县| 安吉县| 北流市| 隆子县| 石门县| 兴宁市| 尤溪县| 汝州市| 平陆县| 宝鸡市| 新建县| 南部县| 西宁市| 城口县| 齐河县| 镇沅| 分宜县| 罗甸县| 通榆县| 玉门市| 洞头县| 凯里市| 白水县| 日土县| 贡嘎县| 静乐县| 兴安盟| 济源市| 广东省| 开江县| 奉化市| 格尔木市| 宁武县| 平南县| 龙井市|