请使用Python画一只乌龟
时间: 2023-04-07 10:04:16 浏览: 170
Python开发之pip安装及使用方法详解
好的,我可以回答这个问题。以下是使用Python绘制乌龟的代码:
```python
import turtle
# 创建一个画布和画笔
canvas = turtle.Screen()
pen = turtle.Turtle()
# 绘制乌龟
pen.color('green')
pen.pensize(5)
pen.speed(1)
# 绘制乌龟的头
pen.penup()
pen.goto(0, 100)
pen.pendown()
pen.circle(50)
# 绘制乌龟的身体
pen.penup()
pen.goto(0, 50)
pen.pendown()
pen.circle(100)
# 绘制乌龟的四肢
pen.penup()
pen.goto(-50, 0)
pen.pendown()
pen.forward(100)
pen.penup()
pen.goto(50, 0)
pen.pendown()
pen.forward(100)
pen.penup()
pen.goto(-70, -50)
pen.pendown()
pen.forward(40)
pen.penup()
pen.goto(30, -50)
pen.pendown()
pen.forward(40)
# 隐藏画笔
pen.hideturtle()
# 关闭画布
canvas.exitonclick()
```
希望这个代码对你有所帮助!
阅读全文