一、代码
import turtle
turtle.pensize(10) #设置画笔大小为10像素
turtle.pencolor('blue') #设置画笔颜色为蓝色
turtle.circle(50) #设置圆的半径为50像素
turtle.pencolor('red')
turtle.circle(-70)
turtle.circle(70,180) #画半圆(圆心角为180°)
#画正方形
turtle.pensize(10)
turtle.pencolor(0.4,0.9,0.1) #用三个0-1的小数设置颜色
for i in range(4):
turtle.forward(100) #海龟画笔前进100像素
turtle.right(90) #画笔向下(前进方向向右)旋转90°
#画五角星
turtle.pensize(10)
turtle.pencolor(1,0,1)
turtle.fd(100)
for i in range(4):
turtle.right(144) #画笔前进方向向右旋转144°
turtle.forward(100)
#五角星2
turtle.pensize(10)
turtle.pencolor('yellow')
for i in range(5):
turtle.left(72)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
二、绘制结果: