画圣诞树——基于turtle的实现
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/90b180419f2063de03e3c039bfc017ab.png)
from turtle import *
import time
def arc_l(initial_degree, range_num, step, rotate_degree):
seth(initial_degree)
for n in range(range_num):
fd(step)
lt(rotate_degree)
def arc_r(initial_degree, range_num, step, rotate_degree):
seth(initial_degree)
for n in range(range_num):
fd(step)
rt(rotate_degree)
def star():
pu()
goto(0, 150)
pd()
seth(72)
for i in range(5):
rt(144)
fd(15)
lt(72)
fd(15)
def no_1():
rt(144)
pu()
fd(43)
pd()
arc_l(-72, 60, 1, 1.1)
pu()
goto(0, 150)
seth(-108)
fd(43)
pd()
arc_r(-108, 60, 1, 1.1)
arc_l(-50, 50, 1, 1.5)
arc_l(-50, 35, 1, 3)
arc_l(-30, 40, 1, 2)
def no_2():
pu()
goto(25, 60)
pd()
arc_l(-80, 80, 1, 1.1)
pu()
goto(-20, 60)
pd()
arc_r(-100, 80, 1, 1.1)
arc_l(-60, 70, 1, 1.2)
arc_l(-40, 45, 1, 2.0)
arc_l(-30, 75, 1, 1.2)
def no_3():
pu()
goto(40, -8)
pd()
arc_l(-80, 80, 1, 1.1)
pu()
goto(-40, -8)
pd()
arc_r(-100, 80, 1, 1.1)
arc_l(-60, 70, 1, 1.2)
arc_l(-50, 85, 1, 1.2)
arc_l(-28, 72, 1, 1.2)
def stump():
pu()
goto(-20, -90)
pd()
seth(-100)
fd(50)
seth(0)
fd(50)
seth(100)
fd(50)
if __name__ == '__main__':
setup(550, 400)
speed(1)
pensize(5)
star()
no_1()
no_2()
no_3()
stump()
done()