Final Exam Review Spring 2003: Converting to Methods
Questions, answers, comments?
(Back to Sp2003 Final Exam Review)
Just an FYI: There is supposed to be an asterisk in the sunset code given for the example...It didn't show up when the professor wrote the problem, but it needs to be there for the code to work. Check the slides from the objects.ppt to get the correct code for makeSunset in method form.
Lauren Biddle
(a)
def clearRed(picture):
for p in getPixels(picture):
p.setRed(p.getRed()*0.0)
(b)
def greyscale(picture):
for p in getPixels(picture):
luminance=((p.getRed()+p.getBlue()+p.getGreen())/3)
p.setColor(makeColor(luminance, luminance, luminance))
(c)
def negative(picture):
for p in getPixels(picture):
p.setColor(makeColor(255-p.getRed(),255-p.getGreen(),255-p.getBlue()))
Lauren Biddle
Will u show the example in each question in the exam like u did here?
| "u"? Is that a variable standing for an unknown quantity? English, please. Mark Guzdial |
"U" means "YOU". could you please answer the question now, sir.
| Sorry – huffier than I meant to be. Yes, I always give you examples to work from if there's code to be written. Mark Guzdial |
Link to this Page