Question: 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
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
