CSC 1301: Principles of Computer Science I - Chapter 9: Dictionaries

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/16

flashcard set

Earn XP

Description and Tags

Key vocabulary and essential operations covering Python dictionaries, common dictionary methods, iteration using view objects, and nested dictionary structures.

17 Terms

1
New cards

Dictionary (dict)

A container object in Python that stores references to objects as key-value pairs, where elements maintain insertion order as of Python 3.7.

2
New cards

Key-value pair

An association where each unique key in a dictionary references and maps to a specific value, analogous to a word and its definition.

3
New cards

my_dict[key]

An indexing operation that retrieves the value associated with the specified key in a dictionary.

4
New cards

my_dict[key] = value

An operation that adds a new entry if the key does not already exist, or modifies the existing entry's value if the key is present.

5
New cards

del my_dict[key]

An operation that deletes the entry with the specified key from a dictionary.

6
New cards

key in my_dict

An expression that tests for the existence of a specified key within a dictionary, returning True if present and False otherwise.

7
New cards

Dictionary method

A function provided by the dict type that operates directly on a specific dictionary object to perform operations such as modifying entries, querying data, or merging.

8
New cards

my_dict.clear()

A dictionary method that removes all items from the dictionary, leaving it empty.

9
New cards

my_dict.get(key, default)

A dictionary method that reads and returns the value of the key; if the key does not exist, it returns the specified default value.

10
New cards

my_dict1.update(my_dict2)

A dictionary method that merges my_dict1 with another dictionary my_dict2, overwriting existing entries in my_dict1 if matching keys exist in my_dict2.

11
New cards

my_dict.pop(key, default)

A dictionary method that removes and returns the value associated with the specified key; if the key does not exist, it returns the provided default value.

12
New cards

View object

A read-only object produced by dict methods (items(), keys(), or values()) that dynamically reflects changes to the dictionary and yields items on demand to conserve memory without supporting direct indexing.

13
New cards

dict.items()

A dictionary method that returns a view object yielding (key, value) tuples for all entries in the dictionary.

14
New cards

dict.keys()

A dictionary method that returns a view object yielding all the keys present in the dictionary.

15
New cards

dict.values()

A dictionary method that returns a view object yielding all the values present in the dictionary.

16
New cards

Nested dictionary

A dictionary structure where the value of an entry is itself another dictionary, accessed using consecutive bracket pairs like dict[key1][key2].

17
New cards

Data structure

A method of organizing data in a logical and coherent fashion, supported by containers like lists and arbitrary levels of nested dictionaries.