This course will become read-only in the near future. Tell us at community.p2pu.org if that is a problem.

Hone Your Powers (Programming) [Jan. 26, 2012, 11:37 a.m.]



The Twitter API search query returns a list of results. For this challenge, you will be putting together some basic code that will help when processing the results of your API call.

You may use Ruby, Python, or any other scripting language of your choice. This challenge is an opportunity for you to demonstrate basic proficiency in that scripting language. If you need to brush up, or if you are using this challenge as a way to guide your learning, that's great too! There's no rush here. Here are some introductory resources for Python and Ruby.

If you have suggestions for other resources, for these languages or others, please submit them as comments below. P2PU and many other sites also offer free courses and tutorials to introduce these languages. 

Make sure to read about for loops, dictionaries (Python) or hashes (Ruby), and if statements. Both Python and Ruby have command line interpreters. Type "python" at the command prompt to enter the Python interpreter, and type "irb" at the command prompt to enter the Ruby interpreter. 

Make a simple dictionary/hash, add some items to it, and experiment with retrieving items by key and by value

Make a list and experiment with adding and retrieving items from it. 

What is the difference (syntactically) between retrieving an item from a dictionary/hash, and a list? 

Write an if statement to check for a value in a list. Then use an if statement to check for a specific key, and return the associated value if that key exists. 

Finally, write a for loop, and iterate over your dictionary/hash. Within the body of the for loop print out each key-value pair.

 How would you insert an if-statement into the for loop?