Created
October 15, 2014 09:58
-
-
Save Inndy/042cb28d4ce60f17979a to your computer and use it in GitHub Desktop.
Guess number game practice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 練習:猜數字遊戲 | |
| from random import randint | |
| r = randint(1, 10) | |
| print("I have a random number: ", r) | |
| secret = _______(1, 100) # 產生一個亂數 | |
| _____ True: # 剛剛教的迴圈 | |
| guess = input("Guess a number:") | |
| guess = ___(_____) # 字串轉成數字 | |
| if _____ __ ______: # 如果猜對了 | |
| print("You got it!") | |
| _____ # 遊戲結束跳出迴圈 | |
| elif _____ _ ______: # 如果猜太大了 | |
| print("Lower please.") | |
| else: | |
| print("Bigger and bigger.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment