import random
fo = open("test.txt", "w")
ans = open("ans.txt", "w")
mm=100
a=[]
b=[]
sign = ['-','+']
for x in range(10,mm):
for y in range(10,mm):
if x+y<mm:
a.append([x,y,1])
if x>y:
a.append([x,y,0])
random.shuffle(a)
lin = 0
mid = 1
for e in a:
fo.write('('+str(mid)+'). '+str(e[0])+sign[e[2]]+str(e[1])+' = ')
if e[2]:
ans.write('('+str(mid)+'). '+str(e[0])+sign[e[2]]+str(e[1])+' = '+str(e[0]+e[1]) )
else:
ans.write('('+str(mid)+'). '+str(e[0])+sign[e[2]]+str(e[1])+' = '+str(e[0]-e[1]) )
lin+=1
mid+=1
if lin==2:
lin=0
fo.write('\r\n')
ans.write('\r\n')
else:
fo.write('\t\t')
ans.write('\t\t')
fo.close()
ans.close()
https://github.com/sofiathefirst/kangkang/blob/master/pupil_math.py