Session 22 Preparation — Videos, Reading and Quizzes
Do this Quiz on
Session 22
as you read the textbook and the web page on formatting.
Print it and complete it using pencil or pen, or fill it in electronically — your choice.
- Here is the quiz in Microsoft Word in case you want to fill it in electronically in that format.
- Dictionaries
- Textbook reading: Section 8.2 — Dictionaries (pages 414-424)
and 8.3.2 — A Dictionary
of Lists (pages 427-429.
- As you read, focus your attention on:
- In the introduction to section 8.2, you should
internalize all aspects of Figure 7.
- 8.2.1. Creating a constant-sized dictionary,
and duplicating a dictionary
Section 9.2 has lots of details about both instance variables and self.
- 8.2.2. Accessing a value form a dictionary by
putting the corresponding key in square brackets.
Using the get method instead, in order to
provide a default value if the searched-for key is not
in the dictionary.
- 8.23. Adding a new item (i.e. a key-value
pair. Changing the value that is associated with a
given key.
- 8.2.4. Remove the item that has a given key,
using the pop method. If there is no such
item, you get a KeyError exception.
- 8.2.5 Iterating through all of the keys or values in
a dictionary for key in my_dictionary: or
for value in my_dictionary.values:
- Table 2. A list of the most common dictionary
functions, methods, and notations.
- Special topic 8.3. Use a dictionary to store
(names and values of) the fields of a data record.
- 8.3.2 The values stored in a dictionary can
themselves be structured data (such as lists, sets, or
dictionaries).
- Main ideas from Session 21.
- In case you missed some of the ideas or do not remember
them, you will find a summary in
this document.
If you have suggestions for improving the document
(especially if they are important things that I omitted),
please send them ot Claude Anderson.