This review is designed for study upon completion of the picture programming assignment. 1. What will the following code print: x=1 while x<5: y=2 while y<4: print '(' , x , ',' , y , ')' # print x and y like (x,y) y=y+1 x=x+1 2. In the above code (1), what would happen if the x=x+1 was indented one more level to the right? 3. What does the following code do? file = pickAFile() pic = makePicture(file) w = getWidth(pic) h = getHeight(pic) targetpic=makeEmptyPicture(w,h) show (targetpic) x = 1 while x<w: y=1 while y<h: pixel = getPixel(pic,x,y) c = getColor(pixel) targetPixel = getPixel(targetpic,x,y) setColor(targetPixel,c) y=y+1 x=x+1 repaint(targetpic) 4. A picture can be scaled to 1/2 its size by creating an empty picture (targetpic), then copying every other pixel from the original picture to the target. How would you modify the above code so that it creates a target picture that is a scaled version of the original picture 'pic'? Show your modifications directly on this page. Terminology 5. For the code above (3), a. list the variables. b. circle a function call that returns a value. What variable catches the return value? c. circle two function calls that do not return a value. |