非常有用的练习表
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()
这个相当有用了,大家拿走用吧!