Python画一个微笑黄豆
时间: 2024-02-12 22:09:47 浏览: 144
以下是Python使用turtle库画一个微笑黄豆的代码:
```python
import turtle
turtle.speed(0)
# 画豆子形状
turtle.penup()
turtle.goto(0, -200)
turtle.pendown()
turtle.fillcolor("yellow")
turtle.begin_fill()
turtle.circle(200)
turtle.end_fill()
# 画眼睛
turtle.penup()
turtle.goto(-80, 60)
turtle.pendown()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.penup()
turtle.goto(80, 60)
turtle.pendown()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
# 画眼珠
turtle.penup()
turtle.goto(-60, 70)
turtle.pendown()
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(15)
turtle.end_fill()
turtle.penup()
turtle.goto(60, 70)
turtle.pendown()
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(15)
turtle.end_fill()
# 画嘴巴
turtle.penup()
turtle.goto(-60, -70)
turtle.pendown()
turtle.pensize(10)
turtle.right(90)
turtle.circle(60, 180)
# 画腮红
turtle.penup()
turtle.goto(-130, -30)
turtle.pendown()
turtle.fillcolor("pink")
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.penup()
turtle.goto(130, -30)
turtle.pendown()
turtle.fillcolor("pink")
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.done()
```
运行代码后,会画出一个微笑的黄豆,包括豆子形状、两个眼睛、眼珠、嘴巴和两个腮红。
阅读全文