Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

write a program that will have tracy draw a row of circles across the c…

Question

write a program that will have tracy draw a row of circles across the canvas. make sure that: each circle has a radius of 10 there are 20 circles drawn along the x-axis hint: remember that in order to have the circles sit next to one another, you need to move forward the diameter between each circle.

Explanation:

Step1: Import Tracy and set up

Import the turtle library (Tracy is a turtle). Set speed and hide the turtle.

import turtle
tracy = turtle.Turtle()
tracy.speed(0)
tracy.hideturtle()

Step2: Define circle-drawing and movement

The diameter is \(2\times10 = 20\). Loop 20 times: draw a circle, then move forward by diameter.

radius = 10
diameter = 2 * radius
for _ in range(20):
    tracy.circle(radius)
    tracy.penup()
    tracy.forward(diameter)
    tracy.pendown()

Step3: Keep window open

Wait for user to close the window.

turtle.done()

Answer:

The Python program (using turtle/Tracy) is as follows:

import turtle
tracy = turtle.Turtle()
tracy.speed(0)
tracy.hideturtle()
radius = 10
diameter = 2 * radius
for _ in range(20):
    tracy.circle(radius)
    tracy.penup()
    tracy.forward(diameter)
    tracy.pendown()
turtle.done()