![](https://img-blog.csdnimg.cn/526ac047915d46e9b0d4de8acc065a85.png)
圣诞节到了,给你最爱的人送上一棵python做的圣诞树吧。
程序员的专属浪漫。我的朋友圈已经让圣诞树刷屏了。
今天来给大家分享一波如何使用 Python 来画一颗圣诞节树,包含多种
版本,从平民版到豪华版
部分代码哦~
import turtle
screen = turtle.Screen()
screen.setup(375, 700)
circle = turtle.Turtle()
circle.shape('circle')
circle.color('red')
circle.speed('fastest')
circle.up()
square = turtle.Turtle()
square.shape('square')
square.color('green')
square.speed('fastest')
square.up()
circle.goto(0, 280)
circle.stamp()
k = 0
for i in range(1, 13):
y = 30 * i
for j in range(i - k):
x = 30 * j
square.goto(x, -y + 280)
square.stamp()
square.goto(-x, -y +