Readings

The readings for Tuesday, November 03 are:

  1. Automate the Boring Stuff with Python

  2. Python for Informatics: Exploring Information

  3. Requests - Quickstart

    Requests should already be installed, so you can skip any instructions about installing it.

Questions

Once you have completed these readings, please answer the following questions:

  1. What are some advantages to using the csv Python module for parsing comma-separated-values, rather than simplying doing str.split?

  2. Use Requests to fetch JSON data from your favorite subreddit:

    # Fetch data from r/Python subreddit
    import requests
    response = requests.get('https://reddit.com/r/Python/.json')
    

    a. How do you access the text of the response?

    b. How do you access the JSON of the response?

    c. Explore the JSON data. Write a code snippet that prints out the title of the subreddit post with the highest score.

Note: If your response object is something like {'error': 429}, then [reddit] thinks you are making too many requests. We can try to trick the website by faking the user-agent as follows:

import requests
headers  = {'user-agent': 'my-python-request'}
response = requests.get('https://reddit.com/r/Python/.json', headers=headers)

Feedback

If you have any questions, comments, or concerns regarding the course, please provide your feedback here.

Submission

To submit your response, please edit the reading08/README.md file in your Bitbucket repository.