怎么用Python绘制五环

2020-10-19 母婴育儿 43阅读

1、创建python文件,test5circle.py;

2、编写python代码,分别定义颜色、圆的位置、圆的半径等,并进行绘画;

import turtle

turtle.color("blue") #定义颜色

turtle.penup()

turtle.goto(-110,-25)

turtle.pendown()

turtle.circle(45) #圆的半径

turtle.color("black")

turtle.penup()

turtle.goto(0,-25)

turtle.pendown()

turtle.circle(45)

turtle.color("red")

turtle.penup()

turtle.goto(110,-25)

turtle.pendown()

turtle.circle(45)

turtle.color("yellow")

turtle.penup()

turtle.goto(-55,-75)

turtle.pendown()

turtle.circle(45)

turtle.color("green")

turtle.penup()

turtle.goto(55,-75)

turtle.pendown()

turtle.circle(45)

input()

3、右击并选择‘在终端中运行Python文件’选项,执行python代码;

4、查看运行结果,可以发现代码绘制的五环;

声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com