def makeQ(self):
nums = [10, 50] # creating array of percentges
num1 = random.choice(nums) # choosing random percentage
nums2 = [10, 20, 40, 100]
print
num2 = random.choice(nums2)
q1 = ("What is {0} percent of {1}?").format(num1, num2) # question string
i = 0
options = []
while (i<4):
options.append(random.randint(0,100))
i+=1
a1 = int((num1 / 100.0) * num2) # num1 is the percentage, which should mutltiply by num2
options.append(a1)
random.shuffle(options)
print("Choose the correct answer: {0}").format(options)
return q1, a1, options
评论列表
文章目录