python运用turtle模块写出庄园是个美女的代码
时间: 2024-04-20 14:17:00 浏览: 113
python 利用turtle模块画出没有角的方格
好的,以下是使用turtle模块绘制庄园是个美女的代码:
```python
import turtle
# 设置画笔速度和颜色
turtle.speed(0)
turtle.bgcolor("lightblue")
turtle.pensize(2)
# 绘制庄园的房子
turtle.color("yellow")
turtle.begin_fill()
for i in range(4):
turtle.forward(200)
turtle.right(90)
turtle.end_fill()
# 绘制房子的屋顶
turtle.color("red")
turtle.penup()
turtle.goto(-100, 100)
turtle.pendown()
turtle.begin_fill()
turtle.goto(0, 200)
turtle.goto(100, 100)
turtle.end_fill()
# 绘制庄园的门
turtle.color("brown")
turtle.penup()
turtle.goto(-50, 0)
turtle.pendown()
turtle.begin_fill()
turtle.goto(-50, -50)
turtle.goto(50, -50)
turtle.goto(50, 0)
turtle.end_fill()
# 绘制庄园的窗户
turtle.color("white")
turtle.penup()
turtle.goto(-100, 50)
turtle.pendown()
turtle.begin_fill()
for i in range(4):
turtle.forward(50)
turtle.right(90)
turtle.end_fill()
turtle.penup()
turtle.goto(50, 50)
turtle.pendown()
turtle.begin_fill()
for i in range(4):
turtle.forward(50)
turtle.right(90)
turtle.end_fill()
# 绘制美女的头发
turtle.color("black")
turtle.penup()
turtle.goto(-50, 150)
turtle.pendown()
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
# 绘制美女的脸
turtle.color("yellow")
turtle.penup()
turtle.goto(-35, 125)
turtle.pendown()
turtle.begin_fill()
turtle.circle(25)
turtle.end_fill()
# 绘制美女的眼睛
turtle.color("black")
turtle.penup()
turtle.goto(-50, 135)
turtle.pendown()
turtle.dot(10)
turtle.penup()
turtle.goto(0, 135)
turtle.pendown()
turtle.dot(10)
# 绘制美女的嘴巴
turtle.color("red")
turtle.penup()
turtle.goto(-25, 110)
turtle.pendown()
turtle.circle(10, -180)
# 隐藏画笔
turtle.hideturtle()
# 结束绘画
turtle.done()
```
运行代码后将会出现一个绘制了庄园与美女的龟画图。注意,此处绘制的美女仅为一个简单的示例,不代表实际情况。
阅读全文