Homework 4

[Note: this webpage last modified Friday, 04-Feb-2011 19:44:51 EST]

This assignment will be handed out at the end of class on Wednesday, September 15 and is due (electronically submitted) before class starts on Wednesday September 22.

For the problems dealing with pictures, I suggest trying them out on real life pictures - pictures of people, buildings, nature, etc. The website http://coweb.cc.gatech.edu/mediaComp-teach#Python for the textbook has a mediasources.zip file that you can download with sample pictures, if you want to use some of the same pictures that the textbook uses. You can also use your own pictures, pictures from the web, etc.

You should create a single Python file for your submission. It will include the code for the functions you are turning in, and you can include additional explanations as Python comments. If you do not turn in your homework in this way, I will take off points!

For each of the following, I have given you what the output should/could look like if you apply the function to the picture that can be downloaded from ../include/banner.jpg and looks like this:

  1. (10 Points) Write a function called mirrorRightToLeft that takes as input a picture that has been loaded into JES. mirrorRightToLeft should take the right-most 1/3 of the picture and mirror that to the left-most 1/3 of the picture. If you load the banner at the top of this webpage into pic, call mirrorRightToLeft(pic), then repaint(pic), you should see a picture that looks like this:

  2. (10 Points) Write a function called times4Image that takes as input a picture that has been loaded into JES. times4Image should create a new picture with makeEmptyPicture that has the same dimensions as the original. times4Image then places 4 copies of the original into the new picture, and then returns the new image with return. If you load the banner at the top of this webpage into pic, call ">>> newPic = times4Image(pic)", then ">>> repaint(newPic)", you should see a picture that looks like this: .

  3. (10 Points) Write a function called winterize that takes as input a picture that has been loaded into JES. winterize should create a new picture that has made green grass and green trees look white instead - like in winter. If you load the banner at the top of this webpage into pic, call ">>> winterize(pic)", then ">>> repaint(pic)", your picture might look something like this:

  4. (10 Points) For this problem, create your own quiz question on Python if/conditional statements (but not a question that has been given on the quizzes or in the textbook). Your quiz question can be multiple choice, fill in the blank, or "explain what this program does". Your quiz question should test knowledge on some "tricky" aspect of programming in Python/JES. You should include the correct answer with the quiz question.