python代码画派大星
时间: 2023-10-12 10:31:01 浏览: 252
以下是 Python 代码画派大星的示例:
```python
import turtle
# 设置画笔
pen = turtle.Turtle()
pen.pensize(5)
pen.speed(5)
# 画身体
pen.fillcolor("yellow")
pen.begin_fill()
pen.circle(150)
pen.end_fill()
# 画眼睛
pen.penup()
pen.goto(-60, 100)
pen.pendown()
pen.fillcolor("white")
pen.begin_fill()
pen.circle(30)
pen.end_fill()
# 画瞳孔
pen.penup()
pen.goto(-60, 110)
pen.pendown()
pen.fillcolor("black")
pen.begin_fill()
pen.circle(15)
pen.end_fill()
# 画鼻子
pen.penup()
pen.goto(0, 50)
pen.pendown()
pen.fillcolor("red")
pen.begin_fill()
pen.circle(20)
pen.end_fill()
# 画嘴巴
pen.penup()
pen.goto(0, 0)
pen.pendown()
pen.right(90)
pen.circle(100, 180)
# 画腮红
pen.penup()
pen.goto(-120, 30)
pen.pendown()
pen.fillcolor("pink")
pen.begin_fill()
pen.circle(30)
pen.end_fill()
pen.penup()
pen.goto(120, 30)
pen.pendown()
pen.fillcolor("pink")
pen.begin_fill()
pen.circle(30)
pen.end_fill()
# 隐藏画笔
pen.hideturtle()
# 保持窗口不关闭
turtle.done()
```
运行代码后,会弹出一个窗口,显示出画出的派大星图案。
阅读全文