python输出一个小熊猫
时间: 2024-03-07 16:22:14 浏览: 101
熊猫.py
你可以使用Python的Turtle模块来画一个小熊猫,以下是示例代码:
```python
import turtle
# 设置初始位置
turtle.penup()
turtle.goto(-50, 150)
turtle.pendown()
# 画头部
turtle.begin_fill()
turtle.color('black')
turtle.circle(100)
turtle.end_fill()
# 画左耳朵
turtle.penup()
turtle.goto(-85, 220)
turtle.pendown()
turtle.begin_fill()
turtle.color('white')
turtle.circle(30)
turtle.end_fill()
# 画右耳朵
turtle.penup()
turtle.goto(35, 220)
turtle.pendown()
turtle.begin_fill()
turtle.color('white')
turtle.circle(30)
turtle.end_fill()
# 画左眼
turtle.penup()
turtle.goto(-40, 80)
turtle.pendown()
turtle.begin_fill()
turtle.color('white')
turtle.circle(30)
turtle.end_fill()
# 画右眼
turtle.penup()
turtle.goto(40, 80)
turtle.pendown()
turtle.begin_fill()
turtle.color('white')
turtle.circle(30)
turtle.end_fill()
# 画左眼珠
turtle.penup()
turtle.goto(-25, 100)
turtle.pendown()
turtle.begin_fill()
turtle.color('black')
turtle.circle(10)
turtle.end_fill()
# 画右眼珠
turtle.penup()
turtle.goto(55, 100)
turtle.pendown()
turtle.begin_fill()
turtle.color('black')
turtle.circle(10)
turtle.end_fill()
# 画鼻子
turtle.penup()
turtle.goto(0, 20)
turtle.pendown()
turtle.begin_fill()
turtle.color('black')
turtle.circle(20)
turtle.end_fill()
# 画嘴巴
turtle.penup()
turtle.goto(-60, -40)
turtle.pendown()
turtle.pensize(5)
turtle.right(45)
turtle.forward(60)
turtle.penup()
turtle.goto(-60, -40)
turtle.pendown()
turtle.left(90)
turtle.forward(60)
# 画左手
turtle.penup()
turtle.goto(-120, -80)
turtle.pendown()
turtle.begin_fill()
turtle.color('black')
turtle.circle(30)
turtle.end_fill()
# 画右手
turtle.penup()
turtle.goto(120, -80)
turtle.pendown()
turtle.begin_fill()
turtle.color('black')
turtle.circle(30)
turtle.end_fill()
# 画左脚
turtle.penup()
turtle.goto(-70, -220)
turtle.pendown()
turtle.begin_fill()
turtle.color('black')
turtle.circle(70, 80)
turtle.circle(10, 160)
turtle.circle(70, 80)
turtle.end_fill()
# 画右脚
turtle.penup()
turtle.goto(70, -220)
turtle.pendown()
turtle.begin_fill()
turtle.color('black')
turtle.circle(-70, 80)
turtle.circle(-10, 160)
turtle.circle(-70, 80)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 等待点击关闭窗口
turtle.done()
```
运行以上代码,就可以在屏幕上看到一个可爱的小熊猫了!
阅读全文