设为首页收藏本站

Crossin的编程教室

 找回密码
 立即加入
楼主: iamocean
打印 上一主题 下一主题

【Python 第9课】random

[复制链接]

4

主题

1

好友

65

积分

注册会员

Rank: 2

楼主
发表于 2018-3-22 12:41:35 |显示全部楼层
from random import randint
num = randint(1,100)
answer = 101


while answer != num:
    print("Guess what I think?")
    answer = int(input())
    if answer < num:
        print("too small,just guess again")
    if answer > num:
        print('too big,just guess again')
    if answer == num:
        print("Congratulations,guess right")
        num = randint(1,100)
        print("Do you want to go on ?")
        answer1 = input()
        if answer1 == "yes":
            continue
        elif answer1 == "no":
            print("Goodbye....")
            break
        else:
            continue

,看着文章,自己写的,不错,加油!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即加入

QQ|手机版|Archiver|Crossin的编程教室 ( 苏ICP备15063769号  

GMT+8, 2024-5-9 10:16 , Processed in 0.026236 second(s), 22 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部