Python综合程序设计,感觉挺难,请求解

产生[1,1000]之间的随机数,利用图形界面设计猜数字游戏程序。程序运行时,输入猜的数据并点击“开始”按钮,判断猜测结果,界面显示当前可猜的数字范围;单击“退出”按钮退出程序运行。

【有帮助请采纳】

from tkinter import *
from random import *

root = Tk()
root.title('猜数字')
root.geometry('500x500+300+100')
num = StringVar()
judge = StringVar()
Entry(root,bg='lightyellow',textvariable=num,font=('微软雅黑',30,'bold'),fg='red',justify='center').place(width=300,height=100,x=100,y=100)
Button(root,text='开始',command=lambda:func(),font=('微软雅黑',25,'bold'),bg='yellow').place(width=180,height=50,x=50,y=350)
Button(root,text='退出',command=root.quit,font=('微软雅黑',25,'bold'),bg='yellow').place(width=180,height=50,x=270,y=350)
Label(root,fg='red',font=('微软雅黑',20,'bold'),textvariable=judge).place(width=300,height=100,x=100,y=200)

def func():
    global num
    n = randint(1,1000)
    if num.get().isdigit():
        N = int(num.get())
        if N>n:
            judge.set('数字过大!')
        elif N<n:
            judge.set('数字过小!')
        else:
            judge.set('恭喜你!猜中了!')
    else:
        judge.set('错误!')

root.mainloop()

img

【有帮助请采纳】

img