一、绘制五角星
import turtle turtle.seth(180) turtle.penup() turtle.fd(65) turtle.pendown() turtle.seth(0) turtle.fillcolor("red") turtle.begin_fill() turtle.fd(130) turtle.seth(-144) turtle.fd(130) turtle.seth(72) turtle.fd(130) turtle.seth(-72) turtle.fd(130) turtle.seth(144) turtle.fd(130) turtle.end_fill()
如图:
二、绘制六角星
import turtle def drawTriangle(): for i in range(3): turtle.fd(60) turtle.left(120) for i in range(6): drawTriangle() turtle.penup() turtle.fd(60) turtle.pendown() turtle.right(60)
如图:
三、绘制叠加三角形
import turtle for i in range(3): turtle.fd(200) turtle.left(120) turtle.penup() turtle.fd(100) turtle.pendown() turtle.left(60) turtle.fd(100) for i in range(2): turtle.left(120) turtle.fd(100)
如图: