猫史档案馆


【Python作品分享】猜数游戏【作品秀】

用户:雾隐3Iu4雾隐3Iu4查看:0 回复:1 评论:0 创建时间:2023-03-18T20:55:37


【作品展示】

center_image

 

【作品介绍】

一个猜数游戏

规则详见游戏

 

【作品源代码】

import random
print("welcome to play.")
print("you should guess a number from 0 to 100")
print("to win you should guess it in eight times,or you will lost")
a=0
com = random.randint(0, 100)
user = int(input('please enter a number that it is between one to a hundred:'))
while True:
    if (com > user):
        print('the number is a bit 喵all.')
        user = int(input('please enter a number that it is between one to a hundred again:'))
        a=a+1
        if a==8:
            print("you are lost")
            break
        else:
            pass
    elif (com < user):
        print('the number is a bit big.')
        user = int(input('please enter a number that it is between one to a hundred:'))
        a=a+1
        if a==8:
            print("you are lost")
            break
        else:
            pass
    
    else:
        print('you have got the true answer!')
        break

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
Python爱好者Python爱好者

新手吧,输入格式不对程序会报错,没事后面会学到怎么解决的

点赞0


评论