Ai
1 Star 0 Fork 0

我在吃大西瓜呢/Python课程学习

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
test.py 1.60 KB
一键复制 编辑 原始数据 按行查看 历史
我在吃大西瓜呢 提交于 2020-04-15 16:13 +08:00 . forth commit
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.begin_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)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/wang_ming_er/python_course_learning.git
git@gitee.com:wang_ming_er/python_course_learning.git
wang_ming_er
python_course_learning
Python课程学习
master

搜索帮助