【跟德天老师学Python】这是一个程序员学习表,相信对你绝对有用,拿走!

非常有用的练习表


def main():
    # 保存题目
    Q1 = "not False"
    Q2 = "not True"
    Q3 = "True or False"
    Q4 = "True or True"
    Q5 = "False or True"
    Q6 = "True and False"
    Q7 = "True and True"
    Q8 = "False and True"
    Q9 = "False and False"
    Q10 = "not(True or False)"
    Q11 = "not(True or True)"
    Q12 = "not(False or True)"
    Q13 = "not(False and True)"
    Q14 = "not(False or False)"
    Q15 = "1 != 0"
    Q16 = "1 != 1"
    Q17 = "0 != 1"
    Q18 = "0 != 0"
    Q19 = "0 != 0"
    Q20 = "1 == 0"
    Q21 = "1 == 1"
    Q22 = "0 == 1"
    Q23 = "0 == 0"

    questions=[Q1,Q2,Q3,Q4,Q5,Q6,
               Q7,Q8,Q9,Q10,Q11,Q12,
               Q13,Q14,Q15,Q16,Q17,Q18,
               Q19,Q20,Q21,Q22,Q23]
    print(len(questions))
    # 保存每个题目的两个答案
    answers=[["True","False"],
             ["True","False"],
             ["True","False"],
             ["True","False"],
             ["True","False"],
             ["True","False"],
             ["True","False"],
             ["True","False"],
             ["True","False"],
             ["True", "False"],
             ["True", "False"],
             ["True", "False"],
             ["True", "False"],
             ["True", "False"],
             ["True", "False"],
             ["True", "False"],
             ["True", "False"],
             ["True", "False"],
             ["True", "False"],
             ["True", "False"],
             ["True", "False"],
             ["True", "False"],
             ["True", "False"]]
    # 保存每个题目的正确答案
    correctAnswers=["A","B","A","A","A","B","A","B","B","B",
                   "B","B","B","A","A","B","A","B","B","B",
                    "A","B","A"]
    # 保存四个选项
    index=["A","B"]
    # 当前题目序号
    currentQuestion = 0;
    # 分数
    point=0;
    # 题库中所有试题
    # i 确定题目序号
    topic_num=0
    while (currentQuestion<len(questions)):
        topic_num+=1
        print("第",topic_num, "题:", questions[currentQuestion])
        for i in range(0,2):

            print(index[i],".",answers[currentQuestion][i])
        userAnswer = input("你的答案:")
        # 默认abcd和大写一样,答对加分
        if userAnswer.lower()==correctAnswers[currentQuestion].lower():
            point+=10
        # 下一题
        currentQuestion+=1
    print("答题结束,您的最后得分一共是:",point)
main()

这个相当有用了,大家拿走用吧!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值