Key Ideas

  • A dictionary is an unordered collection of key-value pairs
  • Creating an empty dictionary: homeruns = {}
  • Adding a key-value pair: homeruns["Babe Ruth"] = 713 (he actually had 714)
  • Adding another pair: homeruns["Mickey Mantle"] = 536
  • Deleting an item: del homeruns["Mickey Mantle"]
  • Modifying an item: homeruns["Babe Ruth"] = 714
  • Determining the number of items in a dictionary: len(homeruns)

In-Class Activity

Active Learning

  • Modify raven.py to count and print the occurences of each letter in the alphabet from ā€˜aā€™ to ā€˜zā€™, regardless of whether it is lowercase or uppercase. Use a dictionary in your solution.

Homework

  • Write a Python program that reads the data from ebird.csv and creates a dictionary out of the data.