import random
right = 0
wrong = 0
print('答题系统,5道题,现在开始!')
count = 1
while count < 6:
a = random.randint(1,20)
b = random.randint(1,20)
s = '+-'
fh = random.choice(s)
if a < b and fh =='-':
result = int(input('%d %s %d =' % (b, fh, a)))
if result == b-a:
print('答对了')
right += 1
else:
print('答错了,答案是:',(b-a))
wrong += 1
elif a > b and fh == '-':
result = int(input('%d %s %d =' % (a, fh, b)))
if result == a-b:
print('答对了')
right += 1
else:
print('答错了,答案是:',(a-b))
wrong += 1
else:
result = int(input('%d %s %d =' % (a, fh, b)))
if result == a+b:
print('答对了')
right += 1
else:
print('答错了,答案是:', (a - b))
wrong += 1
count += 1
print('答题结束,正确%d道,错误%d道' % (right,wrong))