import random
#乘法
def chengfa():
fa=open('二年级数学口算题.txt','a+')
chengshu = str(random.randint(1, 10))
beichengshu =str(random.randint(1, 10))
fa.write(chengshu+'×'+beichengshu+'='+'\t\t')
print(chengshu+'×'+beichengshu+'=',end='\t\t')
fa.close()
#乘加
def chengjia():
fa=open('二年级数学口算题.txt','a+')
chengshu = str(random.randint(1, 10))
beichengshu =str(random.randint(1, 10))
jiashu=str(random.randint(1,20))
fa.write(chengshu+'×'+beichengshu+'+'+jiashu+'='+'\t\t')
print(chengshu+'×'+beichengshu+'+'+jiashu+'=',end='\t\t')
fa.close()
#除法
def chufa():
fa=open('二年级数学口算题.txt','a+')
while True:
chushu=random.randint(2,10)
random python beichushu=random.randint(10,50)
if beichushu%chushu==0:
fa.write(str(beichushu)+'÷'+str(chushu)+'='+'\t\t')
print(str(beichushu)+'÷'+str(chushu)+'=',end='\t\t')
break
fa.close()
if __name__=="__main__":
for i in range(1,800):
a=random.randint(1,3)
if a==1:
chufa()
elif a==2:
chengjia()
else:
chengfa()
if i%3==0:
fa=open('二年级数学口算题.txt','a+')
print()
fa.write('\n')
fa.close()
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论