猫史档案馆


【Python作品分享】数字喵【作品秀】

用户:失控的机器人失控的机器人查看:0 回复:0 评论:0 创建时间:2021-03-27T21:49:43


【作品展示】

center_image

 

【作品介绍】

emmmmm

 

【作品源代码】

import random,turtle
#窗口+画笔工具
ms=turtle.Screen()
ms.setup(1000,600)
mp=turtle.Pen()
mp.hideturtle()
mp.penup()
#生成喵
min_num=1
max_num=100
boom=random.randint(min_num,max_num)
#猜数字
def guess(name):
    global min_num, max_num,playing
    if name == "玩家":
        choose = int(ms.numinput(f"第{bout}回合", f"请输入{min_num}~{max_num}的数字:"))
        mp.goto(0,0)
        mp.clear()
    else:
        choose = random.randint(min_num,max_num)
        mp.goto(0,-100)
    mp.write(f"{name} 选择的数字为{choose}",font=("楷体",30,"normal"),align="center")
    if choose==boom:
        if name == "玩家":
            winner="电脑"
        elif name == "电脑":
            winner = "玩家"
        mp.pencolor("skyblue")
        mp.goto(0,100)
        mp.write(f"{winner}赢了,喵的数字为{boom}",font=("楷体", 30, "normal"), align="center")
        playing = False
    elif choose>boom:
        max_num=choose-1
    elif choose

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页