Here's the code I put together to create concentric circles using Python:

def concentric(myTurtle,number,spacing):
for radius in range(number):
     x = myTurtle.xcor()
     y = myTurtle.ycor()   
     myTurtle.up()
     myTurtle.goto(x,spacing)
     myTurtle.down()   
     drawCircle(myTurtle,radius*y+spacing)
     myTurtle.up()
     myTurtle.goto(x,spacing)
     myTurtle.down()

It, however, has a critical flaw. I need the code to be able to goto any given set of (x,y) coordinates and function correctly, example:

t.up() 
t.goto(-150, -150) 
t.down() 
concentric(t, 6, 10)

The turtle moves to (-150,-150), then, because the code specifies the y-value to be spacing, moves back to the y-value of spacing. How do I get my cTurtle function to accept different y-values, while still using spacing (critical for the concentric circles).

What the heck am I missing?

Thanks!

P.S. Just to keep it honest, this is for a a class project, and I would appreciate it if I could be guided without the answer being "explicity" given (learning, et cetera).

If I have the first goto set to (x,y), the turtle goes to the correct location, draws one circle, then quickly jumps back to "spacing". "y+spacing" does nothing.

Try to find a use for fd() command and left/right moving instead of goto in your program.

from turtle import *

circle(100)
up()
left(90)
fd(100)
left(90)
down()
circle(80)
mainloop()

(If one number in this program is changed and one command is changed, this program draws two concentric circles.)

Why can't the turtle just add the spacing into the y-coordinate?

I speak of turtle module which is standard with Python.

Turtle's direction is tangent to circle and it turns towards it's left where the circle's radius away is the center of drawn circle (and all your circles).

I hope you can draw your circles biggest to smallest.

If first circles radius is r, and spacing is distance between circles, it means that turtle must be just r-spacing distance to left from it's beginning point when it starts next circle, smaller circle.

Drawing a circle is the standard example of programming by teaching turtle to imitate the movements of your own body as you walk a circle yourself and think how to teach turtle to do same. Result is circle routine, which is not telling the radius, but how big step each time the turtle must take and how much it must turn each time. It must turn total of 360 degrees to make the circle.

Tony

I appreciate your advice, but I don't even know.

Got it, the x and y based system I was using in the concentric function was redundant. I needed to compensate for Stop-1 in the range, and my radius formula was flawed.

Note: For any future students doing a similar assignment, send me a message for help! The code above is wrong.

Congrats!

If you like you can post your code to everybody to see (but that maybe disturb teachers from Googlers getting the code for free next time the same assignement comes up). We can maybe suggest some cleanups

Then you can close the discussion as solved.

P.S. This makes two concentric circles by the way:

from turtle import *
r=100 ## radius of current circle
a=20 ## separation

circle(r)
## separation walk pen up
up()
left(90)
fd(a)
right(90) ## restoring direction
down()

r-=a

circle(r)
mainloop()

Here the children's LOGO routine for circle in Python terms

Prove to put accuracy=4. What is meaning of the variable?

from turtle import *
## teach childrens to think by LOGO routine for circle put in Python terms

## higher number, more perfect circle, slower
accuracy=64

dist=400/accuracy  ## how long lines, accuracy*dist desides the size
turn=360/accuracy

down()
for i in range(0,360,turn):
    fd(dist)
    left(turn)

mainloop()

Here the children's LOGO routine for circle in Python terms

Prove to put accuracy=4. What is meaning of the variable?

from turtle import *
## teach childrens to think by LOGO routine for circle put in Python terms

## higher number, more perfect circle, slower
accuracy=64

dist=400/accuracy  ## how long lines, accuracy*dist desides the size
turn=360/accuracy

down()
for i in range(0,360,turn):
    fd(dist)
    left(turn)

mainloop()

I have something similar in my drawCircle. That should just determine the complexity of the circle's circumference.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.