Python实现科赫图形设计

版权声明:本文为博主原创文章,转载请务必注明出处和作者,谢谢合作! https://blog.csdn.net/zhanshen112/article/details/87908424
#KochDrawV1.py
import turtle
def koch(size,n):
    if n==0:
        turtle.fd(size)
    else:
        for i in [0,90,-90,-90,90]:
            turtle.left(i)
            koch(size/3,n-1)
def main():
    turtle.setup(800,600)
    turtle.pu()
    turtle.goto(-200,100)
    turtle.pensize(3)
    turtle.pd()
    level=1
    bianshu=3
    koch(400,level)
    turtle.right(360/bianshu)
    koch(400,level)
    turtle.right(360/bianshu)
    koch(400,level)
    turtle.hideturtle
main()
        
        

猜你喜欢

转载自blog.csdn.net/zhanshen112/article/details/87908424
今日推荐