0

因此,我再次制作表格(数学表格)检查器来检查您的答案。我使用了搜索,但没有找到相关的内容。

def math():
    for f in range (3):
        right=0
        wrong=0
        x=10
        c=5
        p=x*c
        print x,'times',c
        v=read_number('What is the answer?')
        if p==v:
            right=right+1
            print 'You got it right!'
        else:
            wrong=wrong+1
            print 'You got it wrong.'
    for h in range (1)
        print 'You got',right,'right, and',wrong,'wrong'

问题是,当我这样做时,我测试它的最后一个错误,它说:“你得到了 0 对和 1 错”,就像它没有记录答案一样。我究竟做错了什么?

4

1 回答 1

1

对我来说似乎是一个范围问题。

def math():
    for f in range (3):
        right=0
        wrong=0

应该

def math():
    right=0
    wrong=0
    for f in range (3):

所以你不会为每个问题重置rightwrong

于 2014-02-17T19:12:31.827 回答