1.Python蟒蛇绘制
import turtle
turtle.setup(600,450,200,200)
turtle.penup()
turtle.fd(-250)
turtle.seth(-45)
turtle.pencolor("purple")
turtle.pensize(25)
turtle.pendown()
for i in range(5):
turtle.circle(10,180)
turtle.fd(15)
turtle.circle(5,180)
turtle.fd(25)
turtle.done()
2.turtle正方形绘制
import turtle
turtle.setup()
turtle.penup()
turtle.pensize(10)
turtle.goto(-200,-200)
turtle.pendown()
for i in range(4):
turtle.fd(400)
turtle.penup()
turtle.left(90)
turtle.pendown()
turtle.done()
参考代码
import turtle as t
t.pensize(2)
for i in range(4):
t.fd(150)
t.left(90) #转换角度时不需要让海龟飞起来
3.turtle六边形绘制
import turtle
turtle.setup()
turtle.penup()
turtle.pensize(5)
turtle.fd(100)
turtle.pendown()
turtle.left(120)
for i in range(6):
turtle.fd(120)