Students will be able to...
- Define and identify: pop, default value.
- Update values in a dictionary.
- Add values to a dictionary.
- Remove values from a dictionary.
- 6.02 Slide Deck
- Do Now
- Lab - Word Counter (docx) (pdf)
- Solution (access protected resources by clicking on "Additional Curriculum Materials" on the TEALS Dashboard).
- Associated Reading
- Read through the do now, lesson, and lab so that you are familiar with the requirements and can assist students.
Duration | Description |
---|---|
5 Minutes | Do Now |
10 Minutes | Lesson |
35 Minutes | Lab |
5 Minutes | Debrief |
- Display the Do Now on the board.
- Students type code that edits dictionaries by modifying, adding, or removing key:value pairs.
- Discuss what the students learned from Part 1, and go over what the code is doing.
- Describe that you can update a value in a dictionary in a similar way to how you would update a value in a list.
- Discuss what the students learned from Part 2, and go over what the code is doing.
- Note that you can add values to a dictionary by using the same syntax.
- Review: How might you check if a value was in a dictionary before adding it?
- Discuss what the students learned from Part 3, and go over what the code is doing.
- Review what pop does, as well as what the second argument does.
- This is the value that will be returned if the first argument is not in the dictionary.
- Students will create a word count algorithm that will count the number of words in a list of words.
- Talk about any confusion the students had. Discuss additional ideas of how dictionaries might be useful.
Some students may need to be explicitly reminded of the in
keyword to check if a certain key is in their dictionary.