|Welcome to CS1315. Click on the python to add comments.|
|This page removed for FERPA compliance|
Spring 2006 Midterm 1 Review: Match the meaning to the program
Spring 2006 Midterm 1 Review: Match the meaning to the program here.
|The last time I used this example, I asked the architects in the class what the triangular thing was called at the top of a Greek temple. ('REMOVEDd', my preferred word, doesn't sound classical enough!) Apparently, it is called the 'pediment.' So, before anyone asks, that's what pediment means in the question. Sorry, I forgot to check that that was explained before the review questions were posted. We will be REMOVED careful with the actual midterm questions! Colin Potts |
it seems to me that answer for C is 4 and for D is 5? if this is not correct can you pls. explain why?
|You have these backwards. REMOVED out which pixel you're copying and setting the other pixel to. In c, you're using the left pixel for it's color, and changing the right pixel's value to the same thing. So, you're taking the left side and mirroring it on the right side. You're doing the exact opposite of this for D. Student1919|
im confused about the specific order of things. For C:
for y in range(1, getHeight(source) + 1):
for xOffset in range(1, mirrorpoint):
why is it that the for y in range comes before for xOffset for this one while mirroring the top part of the temple in the code for A, the for x in range comes before the for y in range? And why do you use xOffset instead of just saying x?
|Good questions. It doesn't matter in either case. (a) It doesn't matter whether you look at pixels row by row or column by column as long as you do what you have to do to all the target pixels. By putting the y loop outside the xOffset loop, you're doing each row of pixels before shifting down one. By doing the xOffset loop outside the y loop, you're going down each column of pixels before shifting to the right. (b) As for the name of the index variable, 'xOffset' is what it was called in the lecture slide. I agree, it's not particularly REMOVED meaningful than simply calling it 'x'. You can call x and y 'nmrPixelsAcross' and 'nmrPixelsDown' if you like. Colin Potts|
Link to this Page