Question.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:PokeMath 作者: rdp1070 项目源码 文件源码
def makeQ(self):
        nums1 = [1,2,5,10] #creating array of numbers to multiply
        num1 = random.choice(nums1) #choosing random number to multiply
        nums2 = [1,2,3,4,5,6,7,8,9,10]
        num2  = random.choice(nums2)
        q1 = ("What is {0} multiplied by {1}? ").format(num1, num2) #question string
        a1 = int( num1 * num2 ) #What is num1 times num2

        i = 0
        options = []
        while (i<4):
            options.append(random.randint(1, 100))
            i+=1
        options.append(a1)
        random.shuffle(options)
        print("Choose the correct answer: {0}").format(options)
        return q1, a1, options
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号