我想加入皇家空军,并认为这是一种很好的准备方法,我应该为自己编写关于他们的飞机的测验。与洗牌问题进行测验
我已将28架飞机添加到测验中。例如:“台风FGR4基地在哪里?”然后我有7秒钟的时间来思考,然后弹出我要回答的选项。
而不是每次我想它被洗牌时,从第一个问题到最后一个问题以相同的顺序进行测验。
这里是引擎收录http://pastebin.com/wxVus42W
此外,当我已经回答了,我想控制台明确自己在接下来的问题上来问题的测验。
谁能帮助?
谢谢
我想加入皇家空军,并认为这是一种很好的准备方法,我应该为自己编写关于他们的飞机的测验。与洗牌问题进行测验
我已将28架飞机添加到测验中。例如:“台风FGR4基地在哪里?”然后我有7秒钟的时间来思考,然后弹出我要回答的选项。
而不是每次我想它被洗牌时,从第一个问题到最后一个问题以相同的顺序进行测验。
这里是引擎收录http://pastebin.com/wxVus42W
此外,当我已经回答了,我想控制台明确自己在接下来的问题上来问题的测验。
谁能帮助?
谢谢
你想要的是以任何你想要的顺序来调用问题。
通常对于这样的事情,您需要在列表或数组中找到答案。然后对于该列表/数组中的每个项目,显示您想要显示的内容。如果你想改变问题的顺序,你只需洗牌列表/数组。 (面向对象的编程思维方式)
但是看起来它不会将问题加载到列表/数组中。所以,上述不起作用。
dont repeat yourself!,创建方法,增加您的问题和答案除外作为标志
import time
def create_question(question = "", answer = "", excepted = ""):
print (question)
time.sleep(7)
print(answer)
while True:
response = input("Hit 'a', 'b', 'c' or 'd' for your answer\n")
if response == excepted:#CHANGE
print ("Correct!\n")
break
else:
print("Incorrect!!! Try again.")
while True:
response = input("Hit 'a', 'b', 'c' or 'd' for your answer\n")
if response == excepted:#CHANGE
print ("Correct!\n")#CHANGE
stop = True
break
else:
print("Incorrect!!! The Tornado GR4 is based at RAF Marham\n")#CHANGE
stop = True
break
if stop:
break
#first question
create_question(question = "Where is the Tornado GR4 based?",
answer = "a. RAF Marham\nb. RAF Conningsby\nc. RAF Waddington\nd. RAF Church Fenton\n",
excepted = "a")
#second question
create_question(question = "Where is the Typhoon FGR4 Based?",
answer = "a. RAF Marham\nb. RAF Conningsby\nc. RAF Benson\nd. RAF Wyton\n",
excepted = "b")
则需要返工你的代码,并把数组或外部文件的问题。 –
请创建一个[最小,完整,可验证示例](http://stackoverflow.com/help/mcve)并将其添加到您的问题中。 –