计算题生成器(脱式计算,五~六年级(人教版))第三代upgrade版

写在前面

加了封面~

源码

from random import *
from tkinter import *

def topic():
    global A_e,B_e,C_e,D_g,E_g
    A_a = randint(10, 100)
    A_b = randint(10, 100)
    A_c = A_a
    A_d = 100-A_b
    A_e = str(A_a) + '×' + str(A_b) + '+' + str(A_c) + '×' + str(A_d)
    
    B_a = round(uniform(10, 100), 2)
    B_b = round(uniform(10, 100), 2)
    B_c = B_a
    B_d = round(100-B_b, 2)
    B_e = str(B_a) + '×' + str(B_b) + '+' + str(B_c) + '×' + str(B_d)
        
    C_a = round(uniform(10, 100), 2)
    C_b = round(uniform(10, 100), 2)
    C_c = C_a
    C_d = round(100-C_b, 2)
    C_e = str(C_a) + '×' + str(C_b) + '+' + str(C_c) + '×' + str(C_d)
        
    D_a = round(uniform(10, 100), 2)
    D_b = round(uniform(10, 130), 2)
    D_c = D_a
    D_d = randint(100, 130) - round(D_b, 2)
    while D_d < 0:
        D_b = round(uniform(10, 130), 2)
        D_d = round(randint(100, 130) - round(D_b, 2))
    D_e = round(D_b + D_c - 100, 2)
    while D_e < 0:
        D_b = round(uniform(10, 130), 2)
        D_d = randint(100, 130) - round(D_b, 2)
        if D_d < 0:
            D_b = round(uniform(10, 130), 2)
            D_d = round(randint(100, 130) - round(D_b, 2))
        D_e = round(D_b + D_c - 100, 2)
    D_f = D_a    
    D_g = str(round(D_a, 2)) + '×' + str(round(D_b, 2)) + '+' + str(round(D_c, 2)) + '×' +str(round(D_d, 2)) + '-' + str(round(D_f, 2)) + '×' + str(round(D_e, 2))
    
    E_a = round(uniform(10, 100), 2)
    E_b = round(uniform(10, 130), 2)
    E_c = E_a
    E_d = randint(100, 130) - round(E_b, 2)
    while E_d < 0:
        E_b = round(uniform(10, 130), 2)
        E_d = round(randint(100, 130) - round(E_b, 2))
    E_e = round(E_b + E_c - 100, 2)
    while E_e < 0:
        E_b = round(uniform(10, 130), 2)
        E_d = randint(100, 130) - round(D_b, 2)
        if E_d < 0:
            E_b = round(uniform(10, 130), 2)
            E_d = round(randint(100, 130) - round(E_b, 2))
        E_e = round(E_b + E_c - 100, 2)
    E_f = E_a    
    E_g = str(round(E_a, 2)) + '×' + str(round(E_b, 2)) + '+' + str(round(E_c, 2)) + '×' + str(round(E_d, 2)) + '-' + str(round(E_f, 2)) + '×' + str(round(E_e, 2))
    
    
def up_date():
    date = topic()
    label1.config(text=A_e,font=("微软雅黑",15))
    label2.config(text=B_e,font=("微软雅黑",15))
    label3.config(text=C_e,font=("微软雅黑",15))
    label4.config(text=D_g,font=("微软雅黑",15))
    label5.config(text=E_g,font=("微软雅黑",15))
    
def butt():
    label.destroy()
    button.destroy()
    button1 = Button(root,text = '重新生成',width=20,height=1,command = butt)
    button1.place(x=0,y=0)
    timer = root.after(0, up_date)

root = Tk()
root.title("题目生成器 V4.1")
root.geometry("500x500+100+100")

date = topic()
label1 = Label(root, text=' ',font=("微软雅黑",15))
label1.place(x=0,y=30)
label2 = Label(root, text=' ',font=("微软雅黑",15))
label2.place(x=0,y=60)
label3 = Label(root, text=' ',font=("微软雅黑",15))
label3.place(x=0,y=90)
label4 = Label(root, text=' ',font=("微软雅黑",15))
label4.place(x=0,y=120)
label5 = Label(root, text=' ',font=("微软雅黑",15))
label5.place(x=0,y=150)

label = Label(root, text = '欢迎使用题目生成器!',font=('微软雅黑',20))
button = Button(root, text = '生成题目',font=('微软雅黑',15),command = butt)

label.place(x=120,y=150)
button.place(x=190,y=200)
root.mainloop()

效果图

(特别鸣谢C知道!)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值