猫史档案馆


【Python作品分享】电子宠物【作品秀】

用户:阿尔瓦雷斯阿尔瓦雷斯查看:0 回复:0 评论:0 创建时间:2023-04-09T16:09:07


【作品展示】

center_image

 

【作品介绍】

小金鱼

 

【作品源代码】


import random
name="去世"
hp=1000
eggs=0
print("喵金鱼",name,"陪你喵!")

while True:
    mag=input("你要喵金鱼干啥:")
    if mag=="eat":
        hp=hp+random.randint(100,300)
        print("喂食,增长力",hp)
    elif mag=="lay":
        lay=random.randint(10,30)
        hp=hp+random.randint(-300,-100)
        print("产卵数",lay)
        eggs=eggs+lay
    if hp<0:
        print("累嗝屁了")
        break
    elif hp>1500:
        print("吃太多了 嗝屁了")
        break
print("总产卵数:",eggs)

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页