python turtle画4个同心圆方法

如题在线等求大神指教

import turtle
#draw first circle
turtle.penup()
turtle.goto(0,-200)
turtle.pendown()
turtle.circle(200)
#draw second circle
turtle.penup()
turtle.goto(0,-150)
turtle.pendown()
turtle.circle(150)
#draw third circle
turtle.penup()
turtle.goto(0,-100)
turtle.pendown()
turtle.circle(100)
#draw fourth circle
turtle.penup()
turtle.goto(0,-50)
turtle.pendown()
turtle.circle(50)


画笔的坐标默认在0,0,就以它为圆心。

因为turtle画圆的时候是从圆的底部开始画的,所以需要找到四个圆底部的坐标

比如:

第一个半径为200的圆,底部为(0,-200)

第二个半径为150的圆,底部为(0,-150)

第三个半径为100的圆,底部为(0,-100)

第四个半径为  50的圆,底部为(0,  -50)


画的时候按下面的步骤:

    抬起画笔:turtle.penup()

    移动到相应坐标:turtle.goto(坐标)

    放下画笔:turtle.pendown()

    画圆:turtle.circle(半径)


效果如下图所示:



温馨提示:答案为网友推荐,仅供参考
第1个回答  2021-08-19

代码

结果:

结果

可以画任意个同心圆,顺序、大小可改变

第2个回答  2015-09-15
from turtle import *

def test():
reset()
circle(30,-360)
up()
goto(0,-10)
down()
circle(40,-360)
up()
goto(0,-20)
down()
circle(50,-360)
up()
goto(0,-30)
down()
circle(60,-360)

if __name__ == '__main__':
test()

第3个回答  2017-09-12
from turtle import *
def Circle(radius,angle,length):
for i in range(length):
penup()
goto(0,angle)
pendown()
circle(radius)
angle=angle+50
radius=radius-50
Circle(200,-200,4)
done()
相似回答