使用turtle画个绿色小恐龙
时间: 2024-03-01 22:27:33 浏览: 170
好的,以下是使用turtle库画出的绿色小恐龙的代码:
```python
import turtle
# 设置画笔的颜色以及画笔的粗细
turtle.pensize(3)
turtle.pencolor("green")
turtle.fillcolor("green")
# 画出小恐龙的身体
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
# 画出小恐龙的头部
turtle.penup()
turtle.goto(70, 60)
turtle.pendown()
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 画出小恐龙的眼睛
turtle.penup()
turtle.goto(80, 70)
turtle.pendown()
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
# 画出小恐龙的另一个眼睛
turtle.penup()
turtle.goto(60, 70)
turtle.pendown()
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
# 画出小恐龙的嘴巴
turtle.penup()
turtle.goto(75, 50)
turtle.pendown()
turtle.pencolor("black")
turtle.left(90)
turtle.circle(10, 180)
# 画出小恐龙的四条腿
turtle.penup()
turtle.goto(-20, -50)
turtle.pendown()
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(20)
turtle.left(90)
turtle.forward(40)
turtle.right(180)
turtle.forward(40)
turtle.left(90)
turtle.forward(20)
turtle.right(90)
turtle.forward(50)
turtle.penup()
turtle.goto(30, -50)
turtle.pendown()
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(20)
turtle.left(90)
turtle.forward(40)
turtle.right(180)
turtle.forward(40)
turtle.left(90)
turtle.forward(20)
turtle.right(90)
turtle.forward(50)
turtle.hideturtle()
turtle.done()
```
执行该代码,即可在窗口中看到画出的绿色小恐龙。
阅读全文