Mini-project # 2 - "Guess the number" game"
来源:互联网 发布:二叉树递归遍历c语言 编辑:程序博客网 时间:2024/06/12 07:15
========================第一版==============================
# template for "Guess the number" mini-project# input will come from buttons and an input field# all output for the game will be printed in the consoleimport simpleguiimport randomimport math# helper function to start and restart the gamedef new_game(): range100()# define event handlers for control paneldef range100(): print "New Game. Range is 0 to 100" global secret_number secret_number = random.randrange(0, 100) global count, game_choose count = 7 game_choose = 100 print "Number of remaining guesses is", countdef range1000(): print "New Game. Range is 0 to 1000" global secret_number secret_number = random.randrange(0, 1000) global count, game_choose count = 10 game_choose = 1000 print "Number of remaining guesses is", countdef input_guess(guess): global count while count > 0: number = int(guess) print "\n" print "Guess was", number if number < secret_number: print "Higher" elif number > secret_number: print "Lower" else: print "Correct" count = 0 break count -= 1 print "Number of remaining guesses is", count return print "\n" if game_choose == 100: range100() else: range1000()# create framef = simplegui.create_frame("Guess the number", 200, 200)# register event handlers for control elements and start framef.add_button("Range is [0, 100)", range100, 200)f.add_button("Range is [0, 1000)", range1000, 200)f.add_input("Enter a guess", input_guess, 200)# call new_game new_game()# always remember to check your completed program against the grading rubric
0 0
- Mini-project # 2 - "Guess the number" game"
- Interactive Python:Mini-project # 1 - "Guess the number" game"
- 莱斯大学Python课程Mini-project # 2 - "Guess the number" game
- game——Guess the number!
- Mini-project # 3 - "Stopwatch: The Game"
- Guess Number Game
- lintcode:Guess Number Game
- Coursera_An Introduction to Interactive Programming in Python_Mini-project # 2 Guess the number
- Interactive Python:Mini-project # 3 - "Stopwatch: The Game"
- 1562 Guess the number
- Guess the Number
- HDOJ1562 Guess the number
- lintcode(662)Guess Number Game
- lintcode Guess Number Game(Java)
- LintCode Guess Number Game II
- lintcode Guess Number Game II
- EOJ 1095 Guess the Number
- hdu 1562 Guess the number
- kindle无缝迁移笔记
- jquery 相册一下滑动两次
- 【BZOJ3629】[JLOI2014]聪明的燕姿 数学+搜索
- GDI泄露终极解决方案——HOOK API,建立GDI对象引用计数器
- 互联网那一边最好的
- Mini-project # 2 - "Guess the number" game"
- 状态模式(State)
- iOS程序员初学习的Android要点
- Be the Winner+hdu+尼姆博弈
- csdn 待审核
- ArrayList与LinkedList区别
- 备份SQL SERVER远程数据库到本地
- Calenlar 简述
- 从二叉搜索树创建双向有序链表