设计输出一个奥运五环图形
时间: 2024-05-17 14:19:22 浏览: 26
这里给出一个基于 Python 的奥运五环图形的代码实现:
```python
import turtle
# 创建画布和画笔
canvas = turtle.Screen()
pen = turtle.Turtle()
# 设置画笔大小和速度
pen.pensize(6)
pen.speed(10)
# 绘制蓝色圆环
pen.penup()
pen.goto(-120, 0)
pen.pendown()
pen.color("blue")
pen.circle(60)
# 绘制黑色圆环
pen.penup()
pen.goto(0, 0)
pen.pendown()
pen.color("black")
pen.circle(60)
# 绘制红色圆环
pen.penup()
pen.goto(120, 0)
pen.pendown()
pen.color("red")
pen.circle(60)
# 绘制黄色圆环
pen.penup()
pen.goto(-60, -60)
pen.pendown()
pen.color("yellow")
pen.circle(60)
# 绘制绿色圆环
pen.penup()
pen.goto(60, -60)
pen.pendown()
pen.color("green")
pen.circle(60)
# 隐藏画笔,并保持画布不关闭
pen.hideturtle()
canvas.mainloop()
```
运行代码后,会弹出一个窗口,展示出奥运五环图形,如下图所示:
![奥运五环图形](https://cdn.jsdelivr.net/gh/Yidadaa/CDN/img/others/olympic_rings.png)
阅读全文