python用turtle画奥运五环
时间: 2023-11-10 08:06:56 浏览: 86
可以使用以下代码来使用Python的turtle模块画出奥运五环:
```python
import turtle
# 设置窗口大小
turtle.setup(800, 600)
# 画出蓝色圆环
turtle.penup()
turtle.goto(-110, -25)
turtle.pendown()
turtle.color("blue")
turtle.circle(50)
# 画出黄色圆环
turtle.penup()
turtle.goto(0, -25)
turtle.pendown()
turtle.color("yellow")
turtle.circle(50)
# 画出黑色圆环
turtle.penup()
turtle.goto(110, -25)
turtle.pendown()
turtle.color("black")
turtle.circle(50)
# 画出绿色圆环
turtle.penup()
turtle.goto(-55, -75)
turtle.pendown()
turtle.color("green")
turtle.circle(50)
# 画出红色圆环
turtle.penup()
turtle.goto(55, -75)
turtle.pendown()
turtle.color("red")
turtle.circle(50)
# 隐藏画笔
turtle.hideturtle()
turtle.done()
```
输出效果如下:
![奥运五环](https://cdn.jsdelivr.net/gh/YiJiujiu/AI-assistant/img/20210619182548.png)
阅读全文