python3 猜数字游戏

2021-04-27 10:38:56 浏览数 (1)

1、代码 

代码语言:javascript复制
number = 20
flag = True;
while flag:
    sc = int(input('猜数:'))
    if (number == sc):
        print('猜对了')
        flag = False
    elif (sc < number):
        print('猜小了')
    elif sc > number:
        print('猜大了')
else:
    print('恭喜你猜对了')

2、运行结果

0 人点赞