python 小甲鱼猜数字游戏

 

1、

#guess integer game

import random
secret = random.randint(1,10)
temp = input("please input an integer:")
guess = int(temp)
times = 1

while (guess != secret) and (times < 3):
    if guess > secret:
        print("big,big")
    else:
        print("small,small")

    temp = input("please try again:")
    guess = int(temp)
    times += 1

if (guess == secret) and (times <= 3):
    print("you are right.")
else:
    print("three times chance over, game over!")

 

posted @ 2021-02-06 20:38  小鲨鱼2018  阅读(260)  评论(0编辑  收藏  举报