Using turtle to draw Olympic rings in Python

Code reference

#wuhuan.py
import turtle as t #库别名
t.setup(700,400)   #宽度700,高度400,屏幕中心
#蓝环
t.penup()          
t.goto(-80,0)      #到达蓝环起始点
t.pendown()        #到达落笔,开始绘画
t.pencolor("blue")
t.pensize(3)
t.circle(50)
t.penup()          #画完抬笔,去下一个环的起始点
#黑环
t.goto(0,0)
t.pendown()        
t.pencolor("black")
t.pensize(3)
t.circle(50)
t.penup()          
#红环
t.goto(80,0)
t.pendown()
t.pencolor("red")
t.pensize(3)
t.circle(50)
t.penup()
#黄环
t.goto(-40,-80)
t.pendown()
t.pencolor("yellow")
t.pensize(3)
t.circle(50)
t.penup()
#绿环
t.goto(40,-80)
t.pendown()
t.pencolor("green")
t.pensize(3)
t.circle(50)
t.done()

The effect chart is as follows:
Insert picture description here

Published 8 original articles · Likes2 · Visits 319

Guess you like

Origin blog.csdn.net/WHD1998/article/details/104681729