2018年8月25日 星期六

[python]練習一:猜數字

# Python 3

import random

number = random.randrange(1, 100)

while 1==1:
    guess = int(input("Guess a number(1~100):"))

    if guess == number:
        print ("Great! You win!")
        break

    elif guess < number:
        print ("Too small!")

    else:
        print ("Too big!")
 # Python 3

import random

number = random.randrange(1, 100)

while 1==1:
    guess = int(input("Guess a number(1~100):"))

    if guess == number:
        print ("Great! You win!")
        break

    elif guess < number:
        print ("Too small!")

    else:
        print ("Too big!")

 

沒有留言:

熱門文章