请你用Python语言帮我画一个海绵宝宝
时间: 2024-05-15 09:17:14 浏览: 57
Python海绵宝宝源码.py
5星 · 资源好评率100%
好的,以下是Python代码:
```python
import turtle
# 创建画布和画笔
canvas = turtle.Screen()
pen = turtle.Turtle()
# 画海绵宝宝的身体
pen.fillcolor('yellow')
pen.begin_fill()
pen.circle(100)
pen.end_fill()
# 画海绵宝宝的眼睛
pen.penup()
pen.goto(-40, 120)
pen.pendown()
pen.fillcolor('white')
pen.begin_fill()
pen.circle(20)
pen.end_fill()
pen.penup()
pen.goto(-40, 135)
pen.pendown()
pen.fillcolor('black')
pen.begin_fill()
pen.circle(10)
pen.end_fill()
pen.penup()
pen.goto(40, 120)
pen.pendown()
pen.fillcolor('white')
pen.begin_fill()
pen.circle(20)
pen.end_fill()
pen.penup()
pen.goto(40, 135)
pen.pendown()
pen.fillcolor('black')
pen.begin_fill()
pen.circle(10)
pen.end_fill()
# 画海绵宝宝的嘴巴
pen.penup()
pen.goto(-60, 70)
pen.pendown()
pen.pensize(10)
pen.right(90)
pen.circle(60, 180)
# 画海绵宝宝的裤子
pen.penup()
pen.goto(-80, -100)
pen.pendown()
pen.fillcolor('brown')
pen.begin_fill()
pen.forward(160)
pen.right(90)
pen.circle(40, 180)
pen.right(90)
pen.forward(160)
pen.end_fill()
# 画海绵宝宝的鞋子
pen.penup()
pen.goto(-60, -100)
pen.pendown()
pen.fillcolor('black')
pen.begin_fill()
pen.forward(40)
pen.right(90)
pen.forward(20)
pen.right(90)
pen.forward(40)
pen.right(90)
pen.forward(20)
pen.end_fill()
pen.penup()
pen.goto(20, -100)
pen.pendown()
pen.fillcolor('black')
pen.begin_fill()
pen.forward(40)
pen.right(90)
pen.forward(20)
pen.right(90)
pen.forward(40)
pen.right(90)
pen.forward(20)
pen.end_fill()
# 隐藏画笔并退出画布
pen.hideturtle()
canvas.exitonclick()
```
希望你喜欢这个海绵宝宝!
阅读全文