Hone Your Powers Part 1 (Programming)
Prepare the code you will need to process the API response
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.
- Dive Into Python (free online textbook)
- Learning in Python (How to think like a computer scientist series)
- Why's Poignant Guide to Ruby
- Simple google searches will also bring up countless resources explaining the basic logical constructs in all these languages.
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?