#FivePointStar.py
from turtle import *
pensize(5)
pencolor('green')
fillcolor('red')
begin_fill()
while True:
fd(200)
right(144)
if abs(pos()) <1:
break
end_fill()
做好运行点击,如图run

运行结果如下

这样用python做的五角星就出来了。
本文介绍了如何在Python中利用turtle模块绘制一个五角星。通过设置笔的大小、颜色,填充颜色,以及使用循环和条件判断,最终完成五角星的绘制。
#FivePointStar.py
from turtle import *
pensize(5)
pencolor('green')
fillcolor('red')
begin_fill()
while True:
fd(200)
right(144)
if abs(pos()) <1:
break
end_fill()
做好运行点击,如图run

运行结果如下

这样用python做的五角星就出来了。
5587
528