用python画一只乌龟
时间: 2023-10-16 18:10:58 浏览: 61
好的,下面是用Python画一只乌龟的代码:
```python
import turtle
turtle.setup(800, 600)
turtle.speed(10)
turtle.pensize(5)
turtle.penup()
turtle.goto(-200,0)
turtle.pendown()
turtle.color("green")
turtle.begin_fill()
for i in range(5):
turtle.forward(100)
turtle.right(144)
turtle.end_fill()
turtle.penup()
turtle.goto(-50,0)
turtle.pendown()
turtle.color("yellow")
turtle.begin_fill()
for i in range(5):
turtle.forward(100)
turtle.right(144)
turtle.end_fill()
turtle.penup()
turtle.goto(100,0)
turtle.pendown()
turtle.color("red")
turtle.begin_fill()
for i in range(5):
turtle.forward(100)
turtle.right(144)
turtle.end_fill()
turtle.penup()
turtle.goto(-50,100)
turtle.pendown()
turtle.color("blue")
turtle.circle(50)
turtle.penup()
turtle.goto(-100,-100)
turtle.pendown()
turtle.color("black")
turtle.write("Hello, I'm a turtle!", font=("Arial", 16, "normal"))
turtle.done()
```
这是一个简单的乌龟画图程序,可以在Python环境中执行并显示出来。
阅读全文