The most common answer is:
speed(0)
for i in range (25,125,25):
circle(i)
penup()
right(90)
forward(25)
left(90)
pendown()
This code is intended to draw a dartboard-like pattern with concentric circles, each circle with an increasing radius, starting from 25 and increasing by 25 units up to 125 units in radius.
However, there seems to be a slight issue with how the turtle’s position is managed for drawing each circle, which might not produce the intended concentric pattern correctly.
To draw the circles concentrically (centered at the same point), the turtle should move back to the center before drawing each larger circle, rather than moving after drawing a circle.
Here’s a corrected and optimized version of your code:
import turtle
turtle.speed(0) # Set the drawing speed to the fastest
# Position the turtle at the center for the first circle
turtle.penup()
turtle.goto(0, -25) # Adjust so the first circle is centered
turtle.pendown()
for i in range(25, 125, 25):
turtle.circle(i) # Draw a circle with radius 'i'
turtle.penup()
turtle.goto(0, -(i + 25)) # Move turtle back to the center for the next circle
turtle.pendown()
turtle.done() # Keep the window open until manually closed
This code correctly draws a series of concentric circles, starting with a radius of 25 units and increasing in 25-unit increments up to 100 units in radius. The goto
command is used to reposition the turtle for each new circle’s radius, ensuring that all circles are centered on the same point.