用turtle画奥运五环
时间: 2023-11-04 07:50:22 浏览: 89
好的,以下是使用 Python 的 turtle 库画出奥运五环的代码:
```python
import turtle
# 设置画笔的颜色和大小
turtle.pensize(6)
turtle.pencolor('blue')
# 画蓝色的圆
turtle.penup()
turtle.goto(-120, 0)
turtle.pendown()
turtle.circle(60)
# 画黄色的圆
turtle.penup()
turtle.goto(0, 0)
turtle.pendown()
turtle.pencolor('gold')
turtle.circle(60)
# 画黑色的圆
turtle.penup()
turtle.goto(120, 0)
turtle.pendown()
turtle.pencolor('black')
turtle.circle(60)
# 画绿色的圆
turtle.penup()
turtle.goto(-60, -60)
turtle.pendown()
turtle.pencolor('green')
turtle.circle(60)
# 画红色的圆
turtle.penup()
turtle.goto(60, -60)
turtle.pendown()
turtle.pencolor('red')
turtle.circle(60)
# 隐藏画笔
turtle.hideturtle()
# 等待关闭窗口
turtle.done()
```
运行结果如下所示:
![奥运五环](https://cdn.luogu.com.cn/upload/image_hosting/fd8p1s7h.png)
阅读全文