import turtle
radius = 100
turtle.speed(0)
for rings in range(10):
turtle.penup()
turtle.goto(0, -radius)
turtle.pendown()
turtle.circle(radius)
radius += 10
How do you make a circle from origin
-
08-10-2022 - |
Frage
I am trying to draw a target like this:
(source: newscientist.com)
using turtle.
The problem is turtle includes the origin as part of the graph, as opposed to the origin being in the center. My question is, how do I get turtle draw a circle AROUND the origin rather than include it?
import turtle
radius = 100
turtle.speed(0)
for rings in range(10):
turtle.circle(radius)
radius += 10
Lösung
Andere Tipps
It's nicer to use radius as the loop variable
import turtle
turtle.speed(0)
for radius in range(100, 200, 10):
turtle.penup()
turtle.goto(0, -radius)
turtle.pendown()
turtle.circle(radius)
Then you might wish to define a function
import turtle
turtle.speed(0)
def origin_circle(turtle, radius):
turtle.penup()
turtle.goto(0, -radius)
turtle.pendown()
turtle.circle(radius)
for radius in range(100, 200, 10):
origin_circle(turtle, radius)
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow