python 生成减法题100 道
import random
from loguru import logger# logger.add('./log/{time:YYYY-MM-DD}.log', format="{time:YYYY-MM-DD at HH:mm:ss} {level} {message}", filter="", level="INFO", encoding='utf-8',rotation='00:00')
logger.add('./log/三位数减法{time:YYYY-MM-DD}.log', format="{message}", filter="", level="INFO", encoding='utf-8',rotation='00:00')orglist=[]
problemorglist=[]
judgeorglist=[]
for i in range(0,1000):a=random.randint(1,9)b=random.randint(0,9)c=random.randint(0,9)abc=100*(a)+10*b+c# d=random.randint(1,a)d=random.randint(1,9)e=random.randint(0,9)f=random.randint(0,9)def1=100*(d)+10*e+fjudgestr=f"{abc}"+f"{def1}"# print(judgestr)# print(judgeorglist)if judgestr not in judgeorglist:judgeorglist.append(judgestr)problem=f"""{abc}-{def1}="""answer=f"""{abc}-{def1}={abc-def1}"""problemorglist.append(problem)orglist.append(answer)# logger.info(f"""{abc}-{def1}={abc-def1}""")# print(def1)for i in range(0,25):logger.info(f"""第{i+1}行:{problemorglist[4*i]} {problemorglist[4*i+1]} {problemorglist[4*i+2]} {problemorglist[4*i+3]}""")
logger.info(f"下面是答案")
for i in range(0,25):logger.info(f"""第{i+1}行:{orglist[4*i]} {orglist[4*i+1]} {orglist[4*i+2]} {orglist[4*i+3]}""")logger.info(judgeorglist[0:100])