猫史档案馆


【Python作品分享】新的作品-3【作业帖】

用户:极限小白极限小白查看:0 回复:0 评论:0 创建时间:2021-09-21T15:37:05


【作品展示】

center_image

 

【作品介绍】

^^^^^^^^^^^

 

【作品源代码】

import turtle
import time
import sys

__Pen = turtle.Pen()


d = 0
b = []
x = {'1,1': '', '2,1': '', '3,1': '', '1,2': '', '2,2': '', '3,2': '', '1,3': '', '2,3': '', '3,3': '', '1,4': '', '2,4': '', '3,4': ''}
__Pen.speed(1000)

def huabu():

    __Pen.penup()
    __Pen.goto(150, 150)
    __Pen.pendown()
    __Pen.setheading((-90))
    for __count in range(4):
        __Pen.forward(300)
        __Pen.right(90)
    __Pen.penup()
    __Pen.goto(50, 150)
    __Pen.pendown()
    __Pen.goto(50, (-150))
    __Pen.goto((-50), (-150))
    __Pen.goto((-50), 150)
    __Pen.penup()
    __Pen.goto((-150), 50)
    __Pen.pendown()
    __Pen.goto(150, 50)
    __Pen.goto(150, (-50))
    __Pen.goto((-150), (-50))
    __Pen.penup()
    __Pen.goto((-100), 100)
    __Pen.write(x['1,1'])
    __Pen.goto(0, 100)
    __Pen.write(x['1,2'])
    __Pen.goto(100, 100)
    __Pen.write(x['1,3'])
    __Pen.goto((-100), 0)
    __Pen.write(x['2,1'])
    __Pen.goto(0, 0)
    __Pen.write(x['2,2'])
    __Pen.goto(100, 0)
    __Pen.write(x['2,3'])
    __Pen.goto((-100), (-100))
    __Pen.write(x['3,1'])
    __Pen.goto(0, (-100))
    __Pen.write(x['3,2'])
    __Pen.goto(100, (-100))
    __Pen.write(x['3,3'])

__Pen.hideturtle()
ha = '#'
for __count in range(9):
    __Pen.clear()
    huabu()
    print('现在轮到', ha, '下')
    while True:
        i = 0
        c = 0
        ee = 0
        喵 = []
        a = input('请输入坐标:')
        for i in x:
            if (a != i):
                c += 1
        if (c != 9):
            ee += 1
        else:
            print('不存在此坐标!')
        for i in 喵:
            if (a == i):
                c += 1
        if (c != 9):
            ee += 1
        else:
            print('这里已经下过了')
        if (ee == 2):
            break
        print('请重新输入!')
    if (x['1,1'] == x['2,1'] and x['2,1'] == x['3,1'] and x['1,1'] != ''):
        print(ha, '胜利!')
        sys.exit()
    elif (x['1,2'] == x['2,2'] and x['2,2'] == x['3,2'] and x['1,1'] != ''):
        print(ha, '胜利!')
        sys.exit()
    elif (x['1,3'] == x['2,3'] and x['2,3'] == x['3,3'] and x['1,1'] != ''):
        print(ha, '胜利!')
        sys.exit()
    elif (x['1,1'] == x['2,2'] and x['2,2'] == x['3,3'] and x['1,1'] != ''):
        print(ha, '胜利!')
        sys.exit()
    elif (x['3,1'] == x['2,2'] and x['2,2'] == x['1,3'] and x['1,1'] != ''):
        print(ha, '胜利!')
        sys.exit()
    if (ha == '#'):
        ha = '%'
    else:
        ha = '#'

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页