python—猜数字游戏

百般思念 提交于 2020-05-07 16:25:07
from tkinter import *
import tkinter.messagebox as mb
import tkinter.simpledialog as dl

root = Tk()
w = Label(root, text = 'Guess Number Game')
w.pack()

mb.showinfo('Wellcome', 'Wellcome to guess number game')

number = 10

while True:
    guess = dl.askinteger('Number', 'Enter an integer:')
    
    if int(guess) == number:
        mb.showinfo('Hint','Bingo! you guessed it right!')
        break
    elif int(guess) > number:
        mb.showinfo('Hint', 'you guessed it higher than that!')
    else:
        mb.showinfo('Hint', 'you guessed it lower than that!')

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!