从零开始学编程

avore-avatar

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")
StroboBob-avatar

StroboBob

[quote][tid=28795789]Topic[/tid] Post by [uid=25068786]五喵[/uid] (2021-10-04 05:10):

今天学习了下,用了一晚上给儿子弄了个自动生成计算题的代码。小崽子,你十一有福了。
明天,我研究下怎么把结果直接弄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)
[/quote]这是什么语言 我能明白意思但有点一言难尽
Walde🏀-avatar

Walde🏀

[quote][pid=555277166,28795789,1]Reply[/pid] Post by [uid=322017]felord[/uid] (2021-10-04 05:15):

这是什么语言 我能明白意思但有点一言难尽[/quote]目测python[s:a2:偷吃][s:a2:偷吃]
avore-avatar

avore

[quote][pid=555277166,28795789,1]Reply[/pid] Post by [uid=322017]felord[/uid] (2021-10-04 05:15):

这是什么语言 我能明白意思但有点一言难尽[/quote]python

因为我电脑里有deepfacelab,直接拿来就用了,不用搭环境。
Afro Hooligan-avatar

Afro Hooligan

[quote][pid=555277166,28795789,1]Reply[/pid] Post by [uid=322017]felord[/uid] (2021-10-04 05:15):

这是什么语言 我能明白意思但有点一言难尽[/quote]目测是没有把缩进复制过来的python[s:ac:茶]
Nimthedog-avatar

Nimthedog

后排出售游标卡尺
maybeGLITCH-avatar

maybeGLITCH

好家伙600道,你是要你儿子国庆节没有好果汁吃啊[s:a2:doge]
liloh-avatar

liloh

哈哈哈哈哈,你给个100以内的啊
withoutSPRIT-avatar

withoutSPRIT

只是中暑了
Ratric-avatar

Ratric

[quote][tid=28795789]Topic[/tid] Post by [uid=25068786]五喵[/uid] (2021-10-04 05:10):

今天学习了下,用了一晚上给儿子弄了个自动生成计算题的代码。小崽子,你十一有福了。
明天,我研究下怎么把结果直接弄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)
[/quote]pandans库可以直接读写各种数据类型的文件
csv啊excel都行
600道也太狠了
Shakkthi-avatar

Shakkthi

你这写得太复杂了, 用re应该要简单很多
Дмитрий  ППС-avatar

Дмитрий ППС

[s:ac:呆]你儿子反手写了一个自动做计算题
Zehein-avatar

Zehein

pandas 或者 csv
avore-avatar

avore

[quote][pid=555299424,28795789,1]Reply[/pid] Post by [uid=5840]MadMars[/uid] (2021-10-04 09:29):

你这写得太复杂了, 用re应该要简单很多[/quote]求教
17y9-avatar

17y9

等一个儿子反手一个eval解决一切计算题
Vonernue-avatar

Vonernue

[quote][pid=555305092,28795789,1]Reply[/pid] Post by [uid=41408383]kleedyx[/uid] (2021-10-04 09:57):

等一个儿子反手一个eval解决一切计算题[/quote]哈哈哈哈哈
Dilansv-avatar

Dilansv

xlwt了解下