欢迎来到KhqHBU的博客

The less is more.

Python--猜数游戏

#猜数游戏
import random
num_random=random.randint(10,99)
n=0
while True:
    usr_input=input('请输入一个10到99的整数:')
    if usr_input=="q":
        print("程序结束")
        break
    if usr_input.isdigit():
        usr_input = int(usr_input)
        if usr_input>num_random:
            print('猜大了')
            n=n+1
            
        elif usr_input<num_random:
            print('猜小了')
            n=n+1
            
        else:
            print('猜对了,你猜了{}次。'.format(n))
            break
    
    

               错了无数回,同学提示了无数回才敲对,心累。

posted @ 2019-04-10 23:01  KhqHBU  阅读(413)  评论(0编辑  收藏  举报
长风破浪会有时,直挂云帆济沧海。