Pythonクラス成績管理システム

2694 ワード

def enter_score(subject_no):
    for no, name in class_101.items():
        scores[subject_no][no] = \
            int(input("{},{} {}  :". \
                      format(no, name, subjects[subject_no])))
    print(scores)
    x = input(" Enter     ")


def disp_score_table():
    for no in class_101.keys():
        print("{ :<5}:".format(class_101[no]), end="")
        sum = 0
        for subject_no in range(0, 3):
            sum = sum + scores[subject_no][no]
            print("{}:{:>3}".format(subjects[subject_no], \
                                    scores[subject_no][no]), end="")
        print("  :{:>3},  :{:.2f}".formatr(sum, \
                                           float(sum) / len(scores)))
    x = input(" Enter     ")


import os

class_101 = dict()
chi_score = dict()
eng_score = dict()
mat_score = dict()
subjects = ["  ", "  ", "  "]
scores = [chi_score, eng_score, mat_score]


def disp_menu():
    print("Class 101        ")
    print("--------------------------")
    print("1.      ")
    print("2.      ")
    print("3.      ")
    print("4.      ")
    print("5.     ")
    print("6.    ")
    print("---------------------------")


def enter_std_data():
    while True:
        no = int(input("  (0==>    ):"))
        if no <= 0 or no > 100: break
        name = input("  ")
        class_101[no] = name
        print(class_101)

def enter_score(subject_no):
    for no,name in class_101.items():
        scores[subject_no][no]=\
        int(input("{},{} {}  :".\
                  format(no,name,subjects[subject_no])))
    print(scores[subject_no])
    x = input(" Enter     ")


def disp_score_table():
    for no in class_101.keys():
        print("{:<5}".format(class_101[no],end=""))
        sum=0
        for subject_no in range(0,3):
            sum=sum=scores[subject_no][no]
            print("{}:{:>3}".format(subjects[subject_no],\
                        scores[subject_no][no]),end="")
            print("  :{:>3},  :{:.2f}".format(sum,\
                                              float(sum)/len(scores)))
    x = input(" Enter     ")


while True:
    disp_menu()
    user_choice=int(input("       :"))
    if user_choice==1:
        enter_std_data()
    elif user_choice>=2 and user_choice<=4:
        enter_score(user_choice-2)
    elif user_choice==5:
        disp_score_table()
    else:
        break
print("      ,  !")