1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Data Pipelines

Exercise

Parsing data from dictionaries

When JSON data is loaded into memory, the resulting dictionary can be complicated. Key-value pairs may contain another dictionary, such are called nested dictionaries. These nested dictionaries are frequently encountered when dealing with APIs or other JSON data. In this exercise, you will practice extracting data from nested dictionaries and handling missing values.

The dictionary below is stored in the school variable. Good luck!

{
    "street_address": "111 Columbia Street",
    "city": "Manhattan",
    "scores": {
        "math": 657,
        "reading": 601
    }
}

Instructions

100 XP
  • Parse the value stored at the "street_address" key from the school dictionary.
  • Parse the value stored at the "scores" key from the school dictionary.
  • Parse the values stored at the "math", "reading", and "writing" keys from the scores dictionary, and set the default value to 0.