Answered step by step
Verified Expert Solution
Question
1 Approved Answer
What you will do is remove those circle calls from the source code, and instead add a loop that reads from a file to get
What you will do is remove those circle calls from the source code, and instead add a loop that reads from a file to get the data to make the calls to the circle function.
# this code draws a bear made of circles
# by repeatedly calling the circle function.
#
# it could be modified to draw anything
# you want made of circles.
# move the pen without leaving a line
def relocate turt x y :
turt.penup
turt.setx x
turt.sety y
turt.setheading
turt.pendown
# draw a circle at the specified position
def circle turt, x y radius color:
SHIFTX
SHIFTY
SCALE
x x SHIFTX
y y SHIFTY
x x SCALE
y y SCALE
radius radius SCALE
relocate turt xy
turt.color color color
turt.beginfill
turt.circle radius
turt.endfill
# draw crosshairs
def crosshairsturt n:
relocateturtn
turt.setheading
turt.forwardn
relocateturtn
turt.setheading
turt.forwardn
def main:
import turtle
wn turtle.Screen
wnbgcolorgray
tturtle.Turtle
twidth
tspeed
thideturtle
crosshairs t
#######################
# your circles go here
#######################
# circle turtle, x y radius, color
circle t "sienna # ear
circle t "sienna # ear
circle t "chocolate # inner ear
circle t "chocolate # inner ear
circle t "sienna # head
circle t "white" # eye
circle t "white" # eye
circle t "blue # pupil
circle t "blue # pupil
circle t "chocolate # nose
circle t "black" # mouth
#########################
# finished with circles #
#########################
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