import turtle #导入海龟模块库
#初始化画笔,设置画笔属性
t = turtle.Pen() #初始化画笔
t.pensize(10) #设置画笔的宽度
#瓜皮-绿色
t.begin_fill() #准备开始填充图形
t.fillcolor("green") #设置填充颜色为绿色
t.circle(400, extent = 30) #画一个半径400,角度为30的弧
t.goto(0, 400) #设置坐标(0, 400)
t.penup() #抬笔
t.home() #将位置和方向恢复到初始状态,位置初始坐标为(0,0)
t.pendown() #落笔
t.circle(400, extent = -30)#画一个半径400,反方向角度为30的弧
t.goto(0, 400) #设置坐标(0, 400)
t.end_fill() #填充完成
#果肉-红色
t.penup()#抬笔
t.goto(0, 50)#设置坐标(0, 50)
t.setheading(0) #把方向调为default(设置当前朝向为angle角度)
t.pendown()#落笔
t.be加粗样式gin_fill()#准备开始填充图形
t.fillcolor("red")#设置填充颜色为红色
t.circle(350, extent = 30)#画一个反方向半径350,角度为30的弧
t.goto(0, 400)#设置坐标(0, 400)
t.penup()#抬笔
t.goto(0, 50)#设置坐标(0, 50)
t.setheading(0) #把方向调为default(设置当前朝向为angle角度)
t.pendown()#落笔
t.circle(350, extent = -30)#画一个反方向半径350,角度为30的弧
t.goto(0, 400)#设置坐标(0, 400)
t.end_fill()#填充完成
#画西瓜子函数
def _dot(x, y, size): #一个设置西瓜子的函数
t.penup() #抬笔
t.goto(x, y)# 设置坐标(x, y)
t.pendown()# 落笔
t.dot(size)# 画一个size大小圆点
#瓜子
_dot(0, 300, 30)* #调用_dot函数画西瓜子
_dot(50, 200, 30)
_dot(-50, 200, 30)
_dot(0, 100, 30)
_dot(100, 120, 30)
_dot(-100, 120, 30)