第一個Python代碼-猜數字

第一個Python代碼——猜數字

最近有打算學習Python,今天看了看Python編程從入門到實踐的前兩章,動手編了一下書前言中作者Eric Matthes在兒童時期編寫的猜數字的程序
number = 23
running = True
while running:
    guess = int(input('Please Input A Number:'))
    if guess == number:
        print('Congratulations, You Guessed It.')
        cond = input('Would You Like Play Again?(Yes/No):')
        if cond.lower() == 'yes':
            running = True
            print('Guess Gaming Continue...')
        else:
            running = False
    elif guess > number:
        print('No, It Is A Little Higher Than True .')
    else:
        print('No, It Is A Little Lower Than True.')
else:
    print('Thanks For Playing!')
運行結果如下所示

測試

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章