Skip to content

Instantly share code, notes, and snippets.

@Inndy
Created October 15, 2014 09:58
Show Gist options
  • Select an option

  • Save Inndy/042cb28d4ce60f17979a to your computer and use it in GitHub Desktop.

Select an option

Save Inndy/042cb28d4ce60f17979a to your computer and use it in GitHub Desktop.
Guess number game practice
# 練習:猜數字遊戲
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