文章目录
- 0. 基础知识
- 1. 蟒蛇绘制
- 2. 正方形绘制
- 3. 六边形绘制
- 4. 叠边形绘制
- 5. 风轮绘制
0. 基础知识
资料来自中国mooc北京理工大学python课程
1. 蟒蛇绘制
import turtle
turtle.setup(650, 350, 200, 200)
turtle.penup()
turtle.fd(-250)
turtle.pendown()
turtle.pensize(25)
turtle.pencolor("purple")
turtle.seth(-40)
for i in range(4):
turtle.circle(40, 80)
turtle.circle(-40, 80)
turtle.circle(40, 80/2)
turtle.fd(40)
turtle.circle(16, 180)
turtle.fd(40 * 2/3)
turtle.done()
2. 正方形绘制
import turtle as t
t.pensize(2)
for i in range(4):
t.forward(150)
t.left(90)
t.done()
3. 六边形绘制
import turtle as t
t.pensize(5)
for i in range(6):
t.forward(150)
t.left(60)
t.done()
4. 叠边形绘制
import turtle as t
t.pensize(2)
for i in range(9):
t.fd(150)
t.left(80)
t.done()
5. 风轮绘制
import turtle as t
t.pensize(2)
for i in range(4):
t.seth(90*i)
t.fd(150)
t.right(90)
t.circle(-150,45)
t.goto(0,0)
t.done()