用Turtle 绘制五角星,并填充颜色
import turtle
turtle.pensize(5)
turtle.pencolor("red")
turtle.fillcolor("yellow")
turtle.begin_fill()
turtle.forward(200)
turtle.right(144)
turtle.forward(200)
turtle.right(144)
turtle.forward(200)
turtle.right(144)
turtle.forward(200)
turtle.right(144)
turtle.forward(200)
turtle.end_fill()
# 保持窗口打开
turtle.done()
循环实现
import turtle
pen = turtle.Turtle()
pen.pensize(5)
pen.color('red','yellow')
pen.begin_fill()
for i in range(5):
pen.forward(400)
pen.right(144)
pen.end_fill()