[Python] Python Turtle: Draw concentric circles using circle() method

Discussão em 'Python' iniciado por Stack, Maio 23, 2025.

  1. Stack

    Stack Membro Participativo

    I was showing a grandson patterns drawn with Python's Turtle module, and he asked to see concentric circles. I thought it would be faster to use the turtle's circle() to draw them than to write my own code for generating a circle. Ha! I am stuck. I see that the circle produced begins its circumference at the turtle's current location and its direction of drawing depends on turtle's current direction of motion, but I can't figure out what I need to do to get concentric circles. I am not at this point interested in an efficient way of producing concentric circles: I want to see what I have to do to get this way to work:

    def turtle_pos(art,posxy,lift):
    if lift:
    art.penup()
    art.setposition(posxy)
    art.pendown()

    def drawit(tshape,tcolor,pen_color,pen_thick,scolor,radius,mv):
    window=turtle.Screen() #Request a screen
    window.bgcolor(scolor) #Set its color

    #...code that defines the turtle trl

    for j in range(1,11):
    turtle_pos(trl,[trl.xcor()+mv,trl.ycor()-mv],1)
    trl.circle(j*radius)

    drawit("turtle","purple","green",4,"black",20,30)

    Continue reading...

Compartilhe esta Página