avore
2021-09-27T21:05:15+00:00
今天学习了下,用了一晚上给儿子弄了个自动生成计算题的代码。小崽子,你十一有福了。
明天,我研究下怎么把结果直接弄EXCEL里面
import random
n = 0
while n < 600 :
a=random.randint(101,999)
b=random.randint(101,999)
c=random.randint(101,999)
d=random.randint(1,2)
e=random.randint(1,2)
if (d > 1 and e >1 and a+b<1000 and a+b+c<1000 and a+b+c>101 and c!=a and a!=b and b!=c):
f = a + b + c
print(n,"、",end="",sep='');print(a,"+",b,"+",c,"=",end="",sep='');print(" ; ",n,"、",end="",sep='');print(a,"+",b,"+",c,"=",f,sep='')
n += 1
elif (d < 2 and e < 2 and a-b>0 and a-b-c>0 and a-b-c>101 and c!=a and a!=b and b!=c):
f = a - b - c
print(n,"、",end="",sep='');print(a,"-",b,"-",c,"=",end="",sep='');print(" ; ",n,"、",end="",sep='');print(a,"-",b,"-",c,"=",f,sep='')
n += 1
elif (d < 2 and e > 1 and a-b>0 and a-b+c<1000 and a-b+c>101 and c!=a and a!=b and b!=c):
f = a - b + c
print(n,"、",end="",sep='');print(a,"-",b,"+",c,"=",end="",sep='');print(" ; ",n,"、",end="",sep='');print(a,"-",b,"+",c,"=",f,sep='')
n += 1
elif (d>1 and e<2 and a+b<1000 and a+b-c>0 and a+b-c>101 and c!=a and a!=b and b!=c):
f = a + b - c
print(n,"、",end="",sep='');print(a,"+",b,"-",c,"=",end="",sep='');print(" ; ",n,"、",end="",sep='');print(a,"+",b,"-",c,"=",f,sep='')
n += 1
print("done")
明天,我研究下怎么把结果直接弄EXCEL里面
import random
n = 0
while n < 600 :
a=random.randint(101,999)
b=random.randint(101,999)
c=random.randint(101,999)
d=random.randint(1,2)
e=random.randint(1,2)
if (d > 1 and e >1 and a+b<1000 and a+b+c<1000 and a+b+c>101 and c!=a and a!=b and b!=c):
f = a + b + c
print(n,"、",end="",sep='');print(a,"+",b,"+",c,"=",end="",sep='');print(" ; ",n,"、",end="",sep='');print(a,"+",b,"+",c,"=",f,sep='')
n += 1
elif (d < 2 and e < 2 and a-b>0 and a-b-c>0 and a-b-c>101 and c!=a and a!=b and b!=c):
f = a - b - c
print(n,"、",end="",sep='');print(a,"-",b,"-",c,"=",end="",sep='');print(" ; ",n,"、",end="",sep='');print(a,"-",b,"-",c,"=",f,sep='')
n += 1
elif (d < 2 and e > 1 and a-b>0 and a-b+c<1000 and a-b+c>101 and c!=a and a!=b and b!=c):
f = a - b + c
print(n,"、",end="",sep='');print(a,"-",b,"+",c,"=",end="",sep='');print(" ; ",n,"、",end="",sep='');print(a,"-",b,"+",c,"=",f,sep='')
n += 1
elif (d>1 and e<2 and a+b<1000 and a+b-c>0 and a+b-c>101 and c!=a and a!=b and b!=c):
f = a + b - c
print(n,"、",end="",sep='');print(a,"+",b,"-",c,"=",end="",sep='');print(" ; ",n,"、",end="",sep='');print(a,"+",b,"-",c,"=",f,sep='')
n += 1
print("done")