Question: this code draws a bear made of circles # by reading data from a file to get the parameters for the circle function. Will you
this code draws a bear made of circles
# by reading data from a file to get the parameters for the circle function.
Will you please help me find the error in my code?
# move the pen without leaving a line
def relocateturt x y:
turt.penup
turt.setxx
turt.setyy
turt.setheading
turt.pendown
# draw a circle at the specified position
def circleturt x y radius, color:
SHIFTX
SHIFTY
SCALE
x x SHIFTX
y y SHIFTY
x x SCALE
y y SCALE
radius radius SCALE
relocateturt x y
turt.colorcolor color
turt.beginfill
turt.circleradius
turt.endfill
# draw crosshairs
def crosshairsturt n:
relocateturt n
turt.setheading
turt.forwardn
relocateturt n
turt.setheading
turt.forwardn
def main:
import turtle
wn turtle.Screen
wnbgcolorgray
t turtle.Turtle
twidth
tspeed
thideturtle
crosshairst
try:
with opencirclestxtr as file:
for line in file:
data line.stripsplit
x y radius, color mapfloat data
circlet x y radius, color
except FileNotFoundError:
printError: File 'circles.txt not found."
except ValueError:
printError: Invalid data format in 'circles.txt
try:
printClose the window when done viewing."
turtle.done
except:
printDone
if namemain:
main
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
