turtle狗绕五边形练习题

turtle狗绕五边形练习题

turtle的Python编程狗绕五边形
仔细观察图形,请同学们把下面画扇形的代码定义成一个函数,重新编程!

import turtle

d = 50
for i in range(5):
    turtle.fd(50)
    turtle.left(72)

for i in range(2):
    turtle.fd(d)
    turtle.left(72)
turtle.fd(d/2)

turtle.right(90)
turtle.circle(-d/2,72)
turtle.right(90)
turtle.fd(3*d/2)
turtle.right(180)
turtle.fd(3*d/2)
turtle.right(90)
turtle.circle(-3*d/2,72)
turtle.right(90)
turtle.fd(5*d/2)
turtle.right(180)
turtle.fd(5*d/2)
turtle.right(90)
turtle.circle(-5*d/2,360-108)

turtle.right(90)
turtle.fd(3*d/2)
turtle.right(180)
turtle.fd(3*d/2)
turtle.right(90)
turtle.circle(-3*d/2,72)

turtle.right(90)
turtle.fd(d/2)
turtle.right(180)
turtle.fd(d/2)
turtle.right(90)
turtle.circle(-d/2,72)

turtle.ht()
turtle.done()

李兴球

李兴球的博客是Python创意编程原创博客