问:为什么当我有多个整数时,我的 count 函数只能计数为 1?
代码:
import random
while True:
value = 0
count = 0
right_counter = 0
value = int(input("Enter the amount of questions would you like to answer: "))
AVG = right_counter / value
if 0<=value<=10:
for i in range(value):
numb1 = random.randint(0, 12)
numb2 = random.randint(0, 12)
answer = numb1 * numb2
AVG = right_counter / value
problem = input("What is " + str(numb1) + " * " + str(numb2) + "? ")
right_counter =+ 1
if int(problem) == answer:
print("You are Correct! Great Job!".format(right_counter))
elif int(problem) > answer:
print("Incorrect, Your answer is too high!")
elif int(problem) < answer:
print("Incorrect, your answer is too low!")
print("You got",right_counter,"out of",value,"correct, giving you an average of ",AVG,"")
break
else:
print(" Error, Please type a number 1-10 ")
这是输出的样子:
输入您想回答的问题数量: 3
1 * 8 是多少?8
你说得对!做得好!
什么是 11 * 11?122
不正确,你的答案太高了!
什么是 1 * 7?7
你说得对!做得好!
你得到了 1 出 3 正确,给你平均 0.3333333333333333
我在Tutorial上找到了一些帮助,但我无法回答我的问题。