用python画奥运五环
时间: 2023-11-09 15:07:13 浏览: 72
可以使用 Python 的 turtle 库来画出奥运五环。
以下是示例代码:
```python
import turtle
# 创建画布
canvas = turtle.Screen()
canvas.title("Olympic Rings")
canvas.bgcolor("white")
# 创建画笔
pen = turtle.Turtle()
pen.speed(0)
pen.pensize(6)
# 画蓝环
pen.penup()
pen.goto(-110, 0)
pen.pendown()
pen.color("blue")
pen.circle(50)
# 画黄环
pen.penup()
pen.goto(0, 0)
pen.pendown()
pen.color("yellow")
pen.circle(50)
# 画黑环
pen.penup()
pen.goto(110, 0)
pen.pendown()
pen.color("black")
pen.circle(50)
# 画绿环
pen.penup()
pen.goto(-55, -50)
pen.pendown()
pen.color("green")
pen.circle(50)
# 画红环
pen.penup()
pen.goto(55, -50)
pen.pendown()
pen.color("red")
pen.circle(50)
# 隐藏画笔
pen.hideturtle()
# 完成画图
turtle.done()
```
运行代码后,将会弹出一个窗口,画出奥运五环。
阅读全文