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.
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 strange 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.
Rebecca Phillips
| Nice job, Rebecca! Can you post your correct code? Mark Guzdial |
Here's the corrected code:
def byeByeBlue(picture):
for p in getPixels(picture):
if getBlue(p) > 100:
setBlue(p,0)
Rebecca Phillips
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.).
Rebecca Phillips
Link to this Page