帮我使用python当中的turtle 画一个五颜六色的小房子
时间: 2023-05-11 10:02:57 浏览: 173
python用turtle画画
好的,以下是使用 Python 的 turtle 库画一个五颜六色的小房子的代码:
```python
import turtle
# 画红色的房子
turtle.color("red")
turtle.begin_fill()
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.end_fill()
# 画黄色的屋顶
turtle.color("yellow")
turtle.begin_fill()
turtle.left(45)
turtle.forward(70.7)
turtle.right(90)
turtle.forward(70.7)
turtle.end_fill()
# 画绿色的草地
turtle.penup()
turtle.goto(-150, -100)
turtle.pendown()
turtle.color("green")
turtle.begin_fill()
turtle.forward(400)
turtle.right(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(400)
turtle.right(90)
turtle.forward(200)
turtle.end_fill()
# 画蓝色的天空
turtle.penup()
turtle.goto(-150, 100)
turtle.pendown()
turtle.color("blue")
turtle.begin_fill()
turtle.forward(400)
turtle.right(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(400)
turtle.right(90)
turtle.forward(200)
turtle.end_fill()
# 画紫色的门
turtle.penup()
turtle.goto(25, -100)
turtle.pendown()
turtle.color("purple")
turtle.begin_fill()
turtle.forward(50)
turtle.left(90)
turtle.forward(80)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(80)
turtle.end_fill()
# 画橙色的窗户
turtle.penup()
turtle.goto(75, 0)
turtle.pendown()
turtle.color("orange")
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.done()
```
希望这个代码能够帮到你!
阅读全文