首先,我们通过角度、线条长短以及循环来进行五角星的代码编译(五角星的线条颜色和填充颜色由你决定),得到如下代码:
from turtle import *
pensize(5)
color("yellow","red")
begin_fill()
for i in range(1,6):
fd(250)
right(144)
end_fill()
done()
运行结果如下:
绘画成的五角星中间有线条很难看,我们将它去掉,代码如下:
from turtle import *
def line():
fd(75)
penup()
fd(50)
pendown()
fd(75)
pensize(5)
color("yellow","red")
begin_fill()
for i in range(1,5):
line()
right(144)
line()
end_fill()
done()
运行结果如下: