Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Fall 2007 Test 1 Review - Mangle

Post questions here.
is it b?
Nope. Thanks! Brittany Duncan
I think it's C.
I also think it is C.

def mangle(picture):
  for x in range(1,getWidth(picture)/2):
    for y in range(1,getHeight(picture)/2):
      setColor(getPixel(picture,x,y),white)
  for x in range(getWidth(picture)/2,getWidth(picture)):
    for y in range(getHeight(picture)/2,getHeight(picture)):
      setColor(getPixel(picture,x,y),black)


The "mangled" picture has a white square in the top left area and a black square in the bottom right area.

The first nested "for" loop starts from (1,1) and goes to (getWidth/2,getHeight/2) and creates a white quadrilateral. It's starting from the top left corner and ends at the midpoint of the picture.

The second nested "for" loop starts from (getWidth/2,getHeight/2) - the end point of the white quadrilateral - and goes to (getWidth,getHeight). It creates a black quadrilateral.

Alex Young




Link to this Page