W16 - s40328104/2016fallcp_hw GitHub Wiki
#猜數字遊戲
[script type="text/python3"]
from browser import alert
import random
ans = random.randint(1, 100)
a_in = int(input("輸入整數:"))
guess = 1
while ans != a_in:
if a_in < ans:
a_in = int(input("too small"))
else:
a_in = int(input("too big"))
guess += 1
alert("恭喜答對 ,一共猜了" + (str(guess)) + "次")
[/script]