我正在創建一個歐盟測驗。我已經得到了高達:如何創建不含28個「if」語句的歐盟測驗
import random as r
import timeit as tr
import time as t
print "How many questions would you like?"
q = int(raw_input())
count = 0
while q > count:
aus_country = r.randrange(1,29)
from random import choice
if aus_country == 28:
country = "Austria"
country_1 = ['Belgium', 'Bulgaria', 'Croatia', 'Cyprus', 'Czech Republic', 'Denmark', 'Estonia', 'Finland', 'France', 'Germany', 'Greece', 'Hungary', 'Ireland', 'Italy', 'Latvia', 'Lithuania', 'Luxembourg', 'Malta', 'Netherlands', 'Poland', 'Portugal', 'Romania', 'Slovakia', 'Slovenia', 'Spain', 'Sweden', 'United Kingdom']
country = choice(country_1)
print "What is the capital of", country
ans = raw_input()
"""I would not like to have 28 if statements here like:
count = count + 1
不過,我想知道是否有檢查的首都,然後有28如果一個更好的方法之類的語句:
if ans == London and country == United_Kindom:
print "Correct"
if ans == Vienna and country == austria:
print "Correct
...
else:
print "Wrong"