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

This page removed for FERPA compliance
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Midterm Exam 1 Review Spring 2003: Which does which

Try the problem here from Sp 2003 Midterm Review #1


I believe both C and D are correct, though I'm not entirely sure on C.

REMOVEDw would you know if C is right or not? Mark Guzdial


Don't think that C is right...cause it changes if the total distance (all three colors involved) is greater than 100. Can't get D to work on Jes for some reason, however, think it's correct in how it's set up. A and B don't seem right cause they're setting the blue value to 100 not 0. So, between D only or None...any ideas????

None- because once the value is above 100% we see the sREMOVEDge color spots and i do not think you can manipulate the pixels after that because they are lost

Okay, I've tested my hypothesis and I believe it works. D would be correct; however, the "if" line isn't indented. That's why you couldn't get it to work in JES. If you put it in there load the program with "if" indented, it works. As for the 100% thing, that refers to percentages when multiplying. The 100 deals with the distance, not the percentage of blue. That also doesn't make sense; because if you recall, every RGB value can go from 0 to 255.
Student116

Nice job, Rebecca! Can you post your correct code? Mark Guzdial


REMOVED's the corrected code:
def byeByeBlue(picture):
  for p in getPixels(picture):
    if getBlue(p) > 100:
      setBlue(p,0)
Student116




Which runs the same as:
def b(x):
  for q in getPixels(x):
    if getBlue(q) > 100:
      setBlue(q,0)


Yes, they run the same because the word "picture" acts as a variable just as "x" does. I posted that answer to show the one that would have been correct out of the problem (A,B,C,D,etc.).
Student116

Link to this Page