The objective of this mini-lab is to practice debugging code, and to experiment with the JES Watch feature.
#Draw the flag of Kazooistan.
# The flag is square with three colored regions:
# the upper left quadrant is black, the upper right quadrant is orange
# and the bottom half is white.
#Parameter: size -- the width and height of the flag.
#Returns: an image of the flag.
def flag(size):
pic = makeEmptyPicture(size, size, white)
for x in range(1,size+1):
for y in rage(1, size + 1):
pix = getPixel(pic, y, x)
# make the upper left black
if y < (.5 * size) and x < (.5 * size)
setColor(pix, black)
# make the upper right orange
if y < (.5 * size) and y < (.5 * size):
setColor(pix, orange)
return pic
x and y to be watched.
Step through the code several times to see if you have
correctly diagnosed the errors.