07 五角星

截图:

代码:

"""
功能:五角星绘制
版本:2.0
新增功能:使用递归函数
"""
"""
知识点:
turtle
"""
import turtle


# 绘制五角星
def paint(x,y,len):
    turtle.goto(x, y)
    count = 1
    while (count <= 5):
        turtle.forward(len)
        turtle.right(144)
        count += 1

    if len <= 150:
        paint(x,y,len+10)


def main():
    turtle.penup()
    turtle.forward(100)
    turtle.pendown()
    turtle.pensize(2)
    turtle.pencolor('green')
    paint(100,0,100)
    turtle.exitonclick()


if __name__ == '__main__':
    main()

猜你喜欢

转载自blog.csdn.net/shmily_syw/article/details/92115597