用python画一个冰墩墩
时间: 2023-06-11 22:09:52 浏览: 99
以下是使用Python绘制冰墩墩的代码,使用turtle模块绘制:
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor("#87CEEB")
# 画身体
turtle.penup()
turtle.goto(-100, -100)
turtle.pendown()
turtle.color("#F5DEB3", "#F5DEB3")
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 画眼睛
turtle.penup()
turtle.goto(-50, 100)
turtle.pendown()
turtle.color("black", "white")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(-50, 110)
turtle.pendown()
turtle.color("black", "black")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(50, 100)
turtle.pendown()
turtle.color("black", "white")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(50, 110)
turtle.pendown()
turtle.color("black", "black")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 完成绘制
turtle.done()
```
运行代码后将会得到下面的冰墩墩图像:
![冰墩墩](https://img-blog.csdnimg.cn/20210709150542841.png)
阅读全文