目录
输出结果
网络异常,图片无法展示
|
设计思路
1. from tkinter import * 2. import tkinter.simpledialog as dl 3. import tkinter.messagebox as mb 4. 5. root = Tk() 6. w = Label(root, text = "Guess Number Game") 7. w.pack() 8. 9. mb.showinfo("yunyaniu", "Welcome to Guess Number Game") 10. 11. number = 2018 12. while True: 13. guess = dl.askinteger("yunyaniu", "What's your guess?") 14. if guess == number: 15. # New block starts here 16. output = 'Bingo! you guessed it right, but you do not win any prizes!' 17. mb.showinfo("Hint: ", output) 18. break 19. # New block ends here 20. elif guess < number: 21. output = 'No, the number is a higer than that' 22. mb.showinfo("Hint: ", output) 23. else: 24. output = 'No, the number is a lower than that' 25. mb.showinfo("Hint: ", output) 26. mb.showinfo("yunyaniu","Thank you for your participation!") 27. 28. print('Game over!')