def game(n):
#teaches children how to add single digit numbers
import random
firstNum=random.randrange(0,10) #1st random number
secondNum=random.randrange(0,10)#2nd random number
equation=(firstNum + secondNum)
print(firstNum, '+', secondNum, '=')
answer=input('Enter answer: ')
for i in range(n):
if equation == answer:
print('Correct')
else:
print('Incorrect')
输出:
>>> game(3)
7 + 2 =
Enter answer: 9
Incorrect
Incorrect
Incorrect