【发布时间】:2014-03-19 12:27:02
【问题描述】:
我的目标是拥有它,以便它可以随机化问题。
例如,测试开始,第一个问题可能是第 8 题。Question 这个词现在只是一个评论。
我希望它看起来像这样:
What does OSI stand for?
A- Open Systematic Information
B- Open Systems Interconnect
C- Organised Stairway Interweb
D- Open Safe Internet
代码如下:
#Intro
name=input("Hello, what is your name? ")
print()
print ("Hello "+ name)
print()
valid = False
while not valid:
ready=input("Are you ready to begin the test? (Please enter YES/NO)")
print()
if ready.lower() =="yes":
print ("Excellent. Welcome to the Networking Principles test. ")
valid = True
elif ready.lower() =="no":
print ("Okay, tell me when your ready. ")
else:
print ("Please asnwer yes or no")
count=0
if ready.lower()=="yes":
print()
print("Please answer each answer with A,B,C or D only. The test will now begin..."
)
#Question 1
print()
print('What does OSI stand for?')
print()
print("A- Open Systematic Information")
print("B- Open Systems Interconnect")
print("C- Organised Stairway Interweb")
print("D- Open Safe Internet")
answer = input()
if answer.lower() =="b":
print ("Correct, Well Done")
count = count + 1
else:
print ("Wrong Answer. The asnwer was B, OSI stands for Open Systems Interconnect")
#Question 2
print()
print("What is the fourth Layer of the OSI Model?")
print()
print("A- Transport Layer")
print("B- Teleport Layer")
print("C- Telecommunications Layer")
print("D- Topology Layer")
answer = input()
if answer.lower() =="a":
print ("Correct, Well Done")
count = count + 1
else:
print ("Wrong Answer. Layer 4 is the Transport Layer")
【问题讨论】:
-
将所有问题推送到列表中,如果已随机选择,则将其从列表中删除
标签: python python-3.x random