python 画出一只羊
时间: 2023-10-12 17:19:15 浏览: 40
好的,让我用 Python 来画一只羊。以下是代码:
```python
# 导入绘图库
import turtle
# 设置画布大小
turtle.setup(800, 600)
# 画出羊的身体
turtle.penup()
turtle.goto(0, -200)
turtle.pendown()
turtle.begin_fill()
turtle.circle(150)
turtle.end_fill()
# 画出羊的头部
turtle.penup()
turtle.goto(0, 0)
turtle.pendown()
turtle.begin_fill()
turtle.circle(80)
turtle.end_fill()
# 画出羊的眼睛
turtle.penup()
turtle.goto(-50, 60)
turtle.pendown()
turtle.begin_fill()
turtle.circle(15)
turtle.end_fill()
turtle.penup()
turtle.goto(50, 60)
turtle.pendown()
turtle.begin_fill()
turtle.circle(15)
turtle.end_fill()
turtle.penup()
turtle.goto(-50, 70)
turtle.pendown()
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
turtle.penup()
turtle.goto(50, 70)
turtle.pendown()
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
# 画出羊的嘴巴
turtle.penup()
turtle.goto(0, 40)
turtle.pendown()
turtle.right(90)
turtle.circle(40, 180)
# 画出羊的耳朵
turtle.penup()
turtle.goto(-70, 120)
turtle.pendown()
turtle.begin_fill()
turtle.right(50)
turtle.circle(40, -100)
turtle.circle(5, 180)
turtle.circle(40, -80)
turtle.end_fill()
turtle.penup()
turtle.goto(70, 120)
turtle.pendown()
turtle.begin_fill()
turtle.left(50)
turtle.circle(-40, -100)
turtle.circle(-5, 180)
turtle.circle(-40, -80)
turtle.end_fill()
# 画出羊的腿
turtle.penup()
turtle.goto(-90, -200)
turtle.pendown()
turtle.begin_fill()
turtle.right(30)
turtle.circle(30, 180)
turtle.right(60)
turtle.circle(-30, 180)
turtle.end_fill()
turtle.penup()
turtle.goto(90, -200)
turtle.pendown()
turtle.begin_fill()
turtle.left(30)
turtle.circle(-30, 180)
turtle.left(60)
turtle.circle(30, 180)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 关闭绘图窗口
turtle.done()
```
运行该代码,即可绘制一只羊的图片。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)