Question.py 文件源码

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

项目:PokeMath 作者: rdp1070 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号