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()
网友评论