Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This code needs to draw a bear in Python but is not. Can you help me fix my code? Thank you! Import turtle import math
This code needs to draw a bear in Python but is not. Can you help me fix my code? Thank you!
Import turtle
import math
# 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:
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started