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(90)
turt.pendown()
# draw a circle at the specified position
def circle ( turt, x ,y , radius , color):
SHIFT_X =40
SHIFT_Y =30
SCALE =5
x = x - SHIFT_X
y = y - SHIFT_Y
x = x * SCALE
y = y * SCALE
radius = radius * SCALE
relocate (turt, x,y)
turt.color (color , color)
turt.begin_fill()
turt.circle (radius)
turt.end_fill()
# draw crosshairs
def crosshairs(turt, n):
relocate(turt,0-n/2,0)
turt.setheading(0)
turt.forward(n)
relocate(turt,0,0-n/2)
turt.setheading(90)
turt.forward(n)
def main():
import turtle
wn = turtle.Screen()
wn.bgcolor("gray88")
t=turtle.Turtle()
t.width (2)
t.speed (7)
t.hideturtle()
crosshairs( t,400)
#######################
# your circles go here
#######################
# circle( turtle, x, y, radius, color)
circle( t,24,52,10, "sienna4") # ear 1
circle( t,76,52,10, "sienna4") # ear 2
circle( t,22,52,8, "chocolate3") # inner ear 1
circle( t,74,52,8, "chocolate3") # inner ear 2
circle( t,70,30,30, "sienna4") # head
circle( t,37,40,8, "white") # eye 1
circle( t,59,40,8, "white") # eye 2
circle( t,29,36,3, "blue2") # pupil 1
circle( t,51,36,3, "blue2") # pupil 2
circle( t,48,26,8, "chocolate3") # nose
circle( t,44,14,4, "black") # mouth
#########################
# finished with circles #
#########################
try:
print("Close the window when done viewing.")
turtle.done()
except:
...
print("Done.")
if __name__=="__main__":
main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!