我有个家庭作业,就是做个测验。它必须包含一个预定义函数的列表。我对python和代码非常陌生,只能理解基础知识。在我的测验中,我有一个计数器,可以记录问题的对错,并在测验结束时显示出来。当前,摘要会重复倒数计时,直到找到正确答案。我很困惑,明天就要考试了。如果有人有一个简单的记分器,我可以用它来代替我的记分器,也可以帮助修复我的记分器,我将不胜感激:)
我看了代码,但不能确定原因,因为我是新来的
k = 1
while k==1:
#asks user a question
print("Q10 - When was the first ever official Formula 1 race?\n1:1850 2:1950 or 3:Yesterday")
q1 = input ("\n")
intcheck(q1)
#correct answer
if q1 == "2":
r.append(1)
print("Congrats you got it correct\n")
#wrong answer
else:
w.append(1)
print("Tough luck, you got that one wrong!")
# score counter
while len(r) > 0:
resultr += 1
r.remove(1)
while len(w) > 0:
resultw += 1
w.remove(1)
#final scoreboard
print ("===============================================")
print ("----------------End Game Summary---------------")
time.sleep(0.5)
print ("You got",resultw,"wrong and ",resultr," correct")
time.sleep(3)
print (" !Thanks for playing! ")
print ("===============================================")
以下代码可以作为基线:
由于您是python新手,我将向您介绍一点面向对象编程
你只要把每个问题都写成这样:
然后将每个问题添加到循环之前的
questions
列表中随便问什么问题
相关问题 更多 >
编程相关推荐