Python Turtle: Draw concentric circles using circle() method
python, turtle-graphics
Solution
You can do it like this:
import turtle
turtle.penup()
for i in range(1, 500, 50):
turtle.right(90) # Face South
turtle.forward(i) # Move one radius
turtle.right(270) # Back to start heading
turtle.pendown() # Put the pen back down
turtle.circle(i) # Draw a circle
turtle.penup() # Pen up while we go home
turtle.home() # Head back to the start pos
Which creates the picture below:
Basically it moves the turtle down one radius lenght to keep the center point for all the circles in the same spot.
Problem
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) ```