python画小黄人步骤
时间: 2023-06-30 18:27:28 浏览: 113
以下是Python画小黄人的步骤:
1. 导入turtle库
```python
import turtle
```
2. 设置画布和画笔属性
```python
turtle.setup(500, 500)
turtle.pensize(3)
turtle.speed(10)
```
3. 画小黄人的身体
```python
turtle.fillcolor("yellow")
turtle.begin_fill()
turtle.circle(70)
turtle.end_fill()
```
4. 画小黄人的眼睛
```python
turtle.penup()
turtle.goto(-25, 120)
turtle.pendown()
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(25, 120)
turtle.pendown()
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(-25, 130)
turtle.pendown()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(25, 130)
turtle.pendown()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
```
5. 画小黄人的嘴巴
```python
turtle.penup()
turtle.goto(-60, 70)
turtle.pendown()
turtle.right(90)
turtle.circle(60, 180)
```
6. 画小黄人的手
```python
turtle.penup()
turtle.goto(-100, 0)
turtle.pendown()
turtle.right(60)
turtle.forward(70)
turtle.right(30)
turtle.forward(40)
turtle.right(120)
turtle.forward(40)
turtle.right(30)
turtle.forward(70)
turtle.penup()
turtle.goto(100, 0)
turtle.pendown()
turtle.right(60)
turtle.forward(70)
turtle.right(30)
turtle.forward(40)
turtle.right(120)
turtle.forward(40)
turtle.right(30)
turtle.forward(70)
```
7. 画小黄人的脚
```python
turtle.penup()
turtle.goto(-50, -70)
turtle.pendown()
turtle.right(90)
turtle.forward(70)
turtle.right(30)
turtle.forward(40)
turtle.right(120)
turtle.forward(40)
turtle.right(30)
turtle.forward(70)
turtle.penup()
turtle.goto(50, -70)
turtle.pendown()
turtle.right(90)
turtle.forward(70)
turtle.right(30)
turtle.forward(40)
turtle.right(120)
turtle.forward(40)
turtle.right(30)
turtle.forward(70)
```
8. 结束画图
```python
turtle.done()
```
完成以上步骤后,你就可以看到Python画的小黄人了。
阅读全文