基于python 上课点名系统

07.py


# 1、老师可以选择随机抽点,也可以按顺序全部点名
# 2、点名完成后,显示点名信息(到或者未到的信息),并统计统计到的人数

class Stu:
    def __init__(self,no,name):
        self.no = no
        self.name = name
        self.f = 0

def q_dian(ls):
    for a in ls:
        b = input(a.name)
        if b == '1':
            a.f = 1
    print("=============点名情况==================")
    print("学号           姓名          到课情况")
    for c in ls:
        stc = "未到"
        if c.f == 1:
            stc = "已到"
        print("%s           %s          %s" % (c.no, c.name,stc))

def s_dian(ls):
    print("")


if __name__ == '__main__':
    f = True
    stu_list = []
    while f:
        no = input("请输入学号:")
        name = input("请输入姓名:")
        s = Stu(no, name)
        stu_list.append(s)
        a = input("是否继续输入(n:结束)")
        if a == 'n':
            f = False
    ff = True
    while ff:
        print("=============请选择操作==========================")
        r = input("1.随机点名\n2.全部点名\n3.退出程序\n")
        if r == '1':
            s_dian(stu_list)
        elif r == '2':
            q_dian(stu_list)
        elif r == '3':
            ff = False
        else:
            print("选择操作有误!!")

 

你可能感兴趣的:(python,python,点名)