Lesson: Dictionaries Methods

Learning Objectives

Students will be able to...

  • Define and Identify: pop, defualt value
  • Update values in a dictionary
  • Add values to a dictionary
  • Remove values from a dictionary

Materials/Preparation

  • Do Now
  • Lab
  • Solution
  • Associated Reading - section 5.2 of Book
  • Read through the Do Now, lesson, and lab so that you are familiar with the requirements and can assist students

Pacing Guide

Duration Description
5 Minutes Do Now
10 Minutes Lesson
30 Minutes Lab
10 Minutes Debrief

Instructor's Notes

  1. Do Now
    • Display the Do Now on the board
  2. Lesson
    • Ask the students about part 1 of Do Now
      • Describe that you can update a value in a dictionary by setting it like how you would set a list.
    • Ask students about part 2 of Do Now
      • Can add values to the dictionary by using the same syntax.
      • How would you check if a value was in a dictionary before adding it?
    • Ask students about part 3 of the Do Now?
      • What does pop do? What does the second argument do.
        • Second argument is the default value. This is the value that will be returned if the first argument is not in the dictionary.
  3. Lab
    • Students will create a word count algorithm that will count the number of words in a list of words.
  4. Debrief
    • Talk about any confusion the students had. Discuss what dictionaries might be useful for.