请您用python画一个派大星
时间: 2023-10-23 21:11:52 浏览: 246
好的,以下是用 Python 绘制派大星的代码:
```python
import turtle
# 设置画布大小
turtle.setup(800, 600)
# 创建画笔
pen = turtle.Turtle()
# 设置画笔颜色和大小
pen.color('yellow')
pen.pensize(10)
# 绘制派大星的头部
pen.begin_fill()
pen.circle(100)
pen.end_fill()
# 绘制派大星的左眼
pen.penup()
pen.goto(-40, 130)
pen.pendown()
pen.color('white')
pen.begin_fill()
pen.circle(30)
pen.end_fill()
# 绘制派大星的右眼
pen.penup()
pen.goto(40, 130)
pen.pendown()
pen.begin_fill()
pen.circle(30)
pen.end_fill()
# 绘制派大星的左眼珠
pen.penup()
pen.goto(-40, 140)
pen.pendown()
pen.color('black')
pen.begin_fill()
pen.circle(10)
pen.end_fill()
# 绘制派大星的右眼珠
pen.penup()
pen.goto(40, 140)
pen.pendown()
pen.begin_fill()
pen.circle(10)
pen.end_fill()
# 绘制派大星的嘴巴
pen.penup()
pen.goto(-60, 50)
pen.pendown()
pen.color('red')
pen.begin_fill()
pen.right(60)
pen.circle(80, 120)
pen.goto(-60, 50)
pen.end_fill()
# 隐藏画笔
pen.hideturtle()
# 等待窗口关闭
turtle.done()
```
运行以上代码即可在窗口中看到绘制出的派大星。
阅读全文