名师广场

登录
工作室首页 > 话题列表 > 话题详情

只看楼主 #每日一题#-基础-124按需绘制图形

  • 楼主

    王嘉焕

    话题:31

    精华:0

    积分:98

    阅读:526 回复:2 2022-11-30 12:58:31

  • 2楼

    王嘉焕

    话题:31

    精华:0

    积分:98

    import turtle as t

    t.setup(900,900)

    t.speed(100)

    t.penup()

    t.pencolor("red")

    t.pensize(3)

    '''x中间'''

    #正方形左

    for i in range(3):

        t.goto(-300+200*i,0)

        t.pendown()

        t.setheading(45)

        for x in range(4):

            t.forward(50)

            t.right(90)

        t.penup()

    #正方形右

    for i in range(3):

        t.goto(300-200*i,0)

        t.pendown()

        t.setheading(135)

        for x in range(4):

            t.forward(50)

            t.left(90)

        t.penup()

    #圆形

    for h in range(7):

        t.goto(-290+100*h,10)#first 

        t.pendown()

        t.fillcolor('yellow')

        t.begin_fill()

        t.circle(15,360)

        t.end_fill()

        t.penup()

    '''靠近中'''

    #正方形左

    for z in range(2):

        for i in range(3):

            t.goto(-265+200*i,70-140*z+50*z)

            t.pendown()

            t.setheading(0)

            for x in range(4):

                t.forward(50)

                t.right(90)

            t.penup()

            #圆形

        for h in range(3):

            t.goto(-265+200*h,60-120*z)#first 

            t.pendown()

            t.fillcolor('yellow')

            t.begin_fill()

            t.circle(15-30*z,360)

            t.end_fill()

            t.penup()

          #正方形右  

        for i in range(3):

            t.goto(265-200*i,70-140*z+50*z)

            t.pendown()

            t.setheading(180)

            for x in range(4):

                t.forward(50)

                t.left(90)

            t.penup()

            #圆形

        for h in range(3):

            t.goto(265-200*h,60-120*z)#first 

            t.pendown()

            t.fillcolor('yellow')

            t.begin_fill()

            t.circle(-15+30*z,360)

            t.end_fill()

            t.penup()

        '''上左'''

    t.goto(-65,70)

        #正方形2

    for z in range(2):

        for i in range(1,3):

            t.goto(-65,(70+100*i)*(-1)**z)

            t.pendown()

            t.setheading(0)

            for x in range(4):

                    t.forward(50)

                    t.right(90*(-1)**z)

            t.penup()

            #圆形

        for i in range(2):

            t.goto(-65,(260-150*i)*(-1)**z)

            t.pendown()

            t.fillcolor('yellow')

            t.begin_fill()

            t.circle(15*(-1)**z,360)

            t.end_fill()

            t.penup()

        #正方形+圆

    t.goto(-100,0)

    for y in range(2):

        t.goto(-100,195*(-1)**y)

        t.pendown()

        t.setheading(45)

        for x in range(4):

                t.forward(50)

                t.right(90)

        t.penup()

        t.goto(-90,180*(-1)**y)

        t.pendown()

        t.setheading(0)

        t.fillcolor('yellow')

        t.begin_fill()

        t.circle(15*(-1)**y,360)

        t.end_fill()

        t.penup()

    '''上右'''

    t.goto(65,70)

        #正方形2

    for z in range(2):

        for i in range(1,3):

            t.goto(65,(70+100*i)*(-1)**z)

            t.pendown()

            t.setheading(180)

            for x in range(4):

                    t.forward(50)

                    t.left(90*(-1)**z)

            t.penup()

            #圆形

        for i in range(2):

            t.goto(65,(260-150*i)*(-1)**z)

            t.pendown()

            t.fillcolor('yellow')

            t.begin_fill()

            t.circle(15*(-1)**(z+1),360)

            t.end_fill()

            t.penup()

        #正方形+圆

    t.goto(100,0)

    for y in range(2):

        t.goto(100,195*(-1)**y)

        t.pendown()

        t.setheading(135)

        for x in range(4):

                t.forward(50)

                t.left(90)

        t.penup()

        t.goto(90,180*(-1)**y)

        t.pendown()

        t.setheading(0)

        t.fillcolor('yellow')

        t.begin_fill()

        t.circle(15*(-1)**(y),360)

        t.end_fill()

        t.penup()

    '''y中间'''

    #正方形下

    for i in range(3):

        t.goto(0,-300+200*i)

        t.pendown()

        t.setheading(135)

        for x in range(4):

            t.forward(50)

            t.right(90)

        t.penup()

    #正方形上

    for i in range(3):

        t.goto(0,300-200*i)

        t.pendown()

        t.setheading(-45)

        for x in range(4):

            t.forward(50)

            t.right(90)

        t.penup()

    #圆形

    for h in range(7):

        t.goto(10,-290+100*h)#first 

        t.pendown()

        t.fillcolor('yellow')

        t.begin_fill()

        t.circle(-15,360)

        t.end_fill()

        t.penup()

    '''中左'''

     #正方形+圆

    t.goto(-200,100)

    for y in range(2):

        t.goto(-200,100*(-1)**y)

        t.pendown()

        t.setheading(-45+180*y)

        for x in range(4):

                t.forward(50)

                t.right(90)

        t.penup()

        t.goto(-200,90*(-1)**y)

        t.pendown()

        t.setheading(0)

        t.fillcolor('yellow')

        t.begin_fill()

        t.circle(15*(-1)**y,360)

        t.end_fill()

        t.penup()

    '''中右'''

    #正方形+圆

    t.goto(200,100)

    for y in range(2):

        t.goto(200,100*(-1)**y)

        t.pendown()

        t.setheading(-45+180*y)

        for x in range(4):

                t.forward(50)

                t.right(90)

        t.penup()

        t.goto(200,90*(-1)**y)

        t.pendown()

        t.setheading(0)

        t.fillcolor('yellow')

        t.begin_fill()

        t.circle(15*(-1)**y,360)

        t.end_fill()

        t.penup()

    9232218049aa6b139f4fc2d3b997b44.png

    2022-12-01 08:51:10

说:

还能输入140发送

关闭

扫码登录更安全

空间登录

手机扫码,安全登录

二维码已失效 请点击刷新
请打开人人通空间APP扫一扫登录

手机扫码,安全登录

扫描成功!

请在手机上确认登录

取消二维码登录

二维码

名师工作室移动端

  • 扫一扫,直接在手机上打开
  • 随时随地使用工作室
分享
回到顶部