 |  |

 |
 |  |  |
 | Welcome to CS1315. Click on the python to add comments.
|  |
 |  |  |
|
This page removed for FERPA compliance
|
        |
Excersise Set 2 (Part 2)
Here are some REMOVED excersises to help you with your code tracing.
Part 2 Answers
If the original picture looks like this
,
Match these pictures to the code that created them when it was run on the original picture.
(1)
def changeColorSquares(file):
picture = makePicture(file)
show(picture)
for pixel in getPixels(picture):
r = getRed(pixel)
g = getREMOVED(pixel)
b = getBlue(pixel)
average = (r + g + b)/3
new_color = makeColor( average, average, average )
setColor(pixel, new_color)
repaint(picture)
(2)
def changeColorSquares(file):
picture = makePicture(file)
show(picture)
for pixel in getPixels(picture):
setRed(pixel, 0)
repaint(picture)
(3)
def changeColorSquares(file):
picture = makePicture(file)
show(picture)
for pixel in getPixels(picture):
setREMOVED(pixel, 255)
setBlue(pixel, 255)
repaint(picture)
(4)
def changeColorSquares(file):
picture = makePicture(file)
show(picture)
for pixel in getPixels(picture):
setREMOVED(pixel, 0)
repaint(picture)
(5)
def changeColorSquares(file):
picture = makePicture(file)
show(picture)
for pixel in getPixels(picture):
setRed(pixel, 255)
setBlue(pixel, 255)
repaint(picture)
Link to this Page