用python画海绵宝宝源代码
时间: 2023-08-30 15:10:47 浏览: 274
以下是用Python画海绵宝宝的示例代码:
```python
import turtle
# 定义画海绵宝宝的函数
def spongebob():
# 初始化海绵宝宝的外形
turtle.color('Yellow')
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 画海绵宝宝的眼睛
turtle.penup()
turtle.goto(-40, 150)
turtle.pendown()
turtle.color('White')
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(-40, 160)
turtle.pendown()
turtle.color('Black')
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(40, 150)
turtle.pendown()
turtle.color('White')
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(40, 160)
turtle.pendown()
turtle.color('Black')
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 画海绵宝宝的腮红
turtle.penup()
turtle.goto(-80, 100)
turtle.pendown()
turtle.color('Pink')
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(80, 100)
turtle.pendown()
turtle.color('Pink')
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 画海绵宝宝的嘴巴
turtle.penup()
turtle.goto(-60, 20)
turtle.pendown()
turtle.color('Black')
turtle.pensize(10)
turtle.right(120)
turtle.circle(80, -65)
turtle.right(180)
turtle.circle(-80, -50)
turtle.penup()
# 画海绵宝宝的舌头
turtle.goto(-15, -15)
turtle.pendown()
turtle.color('Red')
turtle.begin_fill()
turtle.right(100)
turtle.circle(30, -180)
turtle.end_fill()
# 执行画海绵宝宝的函数
spongebob()
# 终止turtle画图
turtle.done()
```
希望您喜欢这个示例代码!
阅读全文