# python学习之实现简单计算器（加减乘除）小学生能力测试

## 1.小学生算术能力测试系统:

import random
count = 0
right = 0
op = ['+','-','*','/']

while True:
a= random.randint(0,9)
b= random.randint(0,9)
s = random.choice(op)
print('%d %s %d = ' %(a,s,b))
question = input('请输入您的答案:(q退出)')
if s == '+':
result = a + b
if s == '-':
result = a - b
if s == '*':
result = a * b
if s == '/':
result = a // b
if question == str(result):
print('回答正确')
right += 1
count += 1
elif question == 'q':
break
else:
print('回答错误')
count += 1

percent = right / count
print('测试结束,共回答%d道题,正确个数为%d,正确率为%.2f%%' %(count,right,percent * 100))


## 2.设计一个程序，帮助小学生练习10以内的加法

import random
count = 0 #定义技术七记录总的题目数
right = 0 #定义计数器记录正确数目
while True:
a= random.randint(0,9)
b= random.randint(0,9)
print('%d + %d = ' %(a,b))
question = input('请输入您的答案:(q退出)')
result = a + b
if question == str(result):
print('回答正确')
right += 1
count += 1
elif question == 'q':
break
else:
print('回答错误')
count += 1

percent = right / count
print('测试结束,共回答%d道题,正确个数为%d,正确率为%.2f%%' %(count,right,percent * 100))