python用turtle画圣诞树
时间: 2023-12-25 18:30:17 浏览: 99
python +turtle 画圣诞树
以下是使用Python的turtle库绘制圣诞树的示例代码:
```python
import turtle
# 设置画布和画笔
canvas = turtle.Screen()
canvas.bgcolor("black")
pen = turtle.Turtle()
pen.speed(1)
pen.color("green")
# 绘制圣诞树
pen.penup()
pen.goto(-50, -200)
pen.pendown()
pen.begin_fill()
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left(75)
pen.forward(250)
pen.right(150)
pen.forward(250)
pen.left
阅读全文