Skip to content

Nov 08: Quiz 5a, Lists of Lists

Learning Objectives

After today's class, you should be able to:

  • Describe how any kind of data can be represented with lists and dictionaries.

Announcements

Haiku Debrief

  • haiku_checker.py
  • Work on projects in VS Code
  • Note: Use Thonny on quizzes

Quiz 5a

  • Log in as student
  • Only two windows:
    1. Thonny
    2. Web browser
  • Web traffic monitored
  • Log out when finished

Ch11 Preview

  • CORGIS
    • Collection of Really Great, Interesting, Situated Datasets
  • Example: County Demographics
  • List comprehensions!
    • Ex: [x ** 2 for x in range(10)]

CSV example:

import csv
from pprint import pprint

data = []
with open("county_demographics.csv") as file:
    reader = csv.reader(file)
    data = [row for row in reader]

pprint(data[0])

JSON example:

import json
from pprint import pprint

with open("county_demographics.json") as file:
    data = json.load(file)

for item in data:
    if item["County"] == "Harrisonburg city":
        pprint(item)