Assignment: Flickr wallpaper

posted by: Ms. Martin 7 June 2010 No Comment

This assignment is designed to give you experience with reading and interpreting existing code while learning about the types of applications made possible by access to online information.

You will need to download flickr.py and wallpaper.py.  Make sure to save them in the same folder.  flickr.py is a library that contains functions to make calls to Flickr.  wallpaper.py is an example of a program using that library.

Run wallpaper.py a couple of times and make sure you understand what it’s doing.  READ THROUGH THE CODE ONCE BEFORE STARTING THE QUESTIONS!

Answer the following questions on a piece of paper to turn in:

  1. What is an API? (look it up and make sure you write a definition you understand, not just one you copy!)
  2. Give three examples of web-based APIs (other than Flickr).
  3. Look on the right side of this page to see the different kinds of information that can be requested from Flickr.  Come up with 2 ideas of little programs you could build (like this wallpaper one) using some of those methods.  Take a look at the app garden for ideas.
  4. Notice that both files start with a comment style we haven’t talked about which uses triple quotes (“”").  Why do you think the original authors used this comment style over the one we know? (#)
  5. Notice that in wallpaper.py, imports are done differently than the ‘from X import *’ style we know.  Take a minute to look through the file and see if you can figure out what the difference is (look at random since you’re familiar with it).  If you can’t figure it out, read the note found here.  What is an advantage of importing modules the way this program does it as opposed to how we did it?  Why do you think I showed ‘from X import *’ to you first?
  6. What does return do? Use context clues if you can’t remember or read a book chapter here.
  7. What changes would you make to wallpaper.py to have the resulting image saved as a different file name?
  8. What are two ways to make a 3×3 grid of pictures rather than the current 4×4?  Describe the changes necessary.
  9. How and why is the split() method used?
  10. On line 31 of the wallpaper.py file, a call on the photos_search function of the flickr module is made.  Notice that parameters are passed in differently from what we have learned.  Look in flickr.py to explain why the parameters are passed as tags=tags, per_page=number instead of tags, number
  11. The wallpaper.py file defines 4 functions.  Describe what input each takes and what steps it completes in detail (essentially, you should be writing pseudocode for the existing program).
  12. How many calls to the Flickr servers does the wallpaper program need to make every time it’s called?  Explain.
  13. Describe how comments are used in the flickr.py file.  Are they helpful in understanding the program?
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>