美文网首页
2019-03-06 turtle案例之二:五彩的蛇

2019-03-06 turtle案例之二:五彩的蛇

作者: 有几米爱音乐 | 来源:发表于2019-03-06 17:37 被阅读0次

    turtle案例之二:五彩的蛇

    描述

    利用turtle库画蛇,每一段的颜色分别为"red", "blue", "green", "yellow","purple"


    输出格式

    答案

    import turtle
    colors=("red", "blue", "green", "yellow","purple")
    turtle.setup(650, 350, 200, 200)
    turtle.penup()
    turtle.fd(-250)
    turtle.pendown()
    turtle.pensize(25)
    turtle.seth(-40)
    for i in range(4):
        turtle.pencolor(colors[i])
        turtle.circle(40, 80)
        turtle.circle(-40, 80)
    turtle.circle(40, 80/2)
    turtle.pencolor("purple")
    turtle.fd(40)
    turtle.circle(16, 180)
    turtle.fd(40 * 2/3)
    turtle.done()
    

    相关文章

      网友评论

          本文标题:2019-03-06 turtle案例之二:五彩的蛇

          本文链接:https://www.haomeiwen.com/subject/ivyxpqtx.html