import time, random
tries= 0
correct = 0
numberOfQuestion = 10
for i in range(1, numberOfQuestion+1):
num1 =random.randint(0, 9)
num2 = random.randint(0, 9)
while True:
print(f'#{i}: {num1} * {num2} = ?')
T1 = time.time()
answer = input('>>>')
T2 = time.time()
total_time = T2-T1
if answer.isdigit():
answer = int(answer)
if total_time > 8:
print('Time is out!')
break
if answer != num1 * num2:
print('incorrect!')
tries +=1
if tries > 2:
print('Out of tires')
break
if answer == num1 * num2:
print('correct!')
time.sleep(1)
correct += 1
break
print(f'Score: ', correct/numberOfQuestion)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)