Integral Marking Scheme version 2024/2025
Dictionary key characteristic - correct answer They are
unique and immutable.
Dictionary method - correct answer D1[key]. remove(value)
dict.items() - correct answer returns a view object that yields
(key, value) tuples.
dict.keys() - correct answer returns a view object that yields
dictionary keys.
dict.values() - correct answer returns a view object that
yields dictionary values.
Dict for loop - correct answer A for loop over a dict retrieves
each key in the dict.
ie.. for key in dictionary:
dict operations - correct answer my_dict[key]
Indexing operation - retrieves the value associated with key.
john_grade = my_dict['John']
my_dict[key] = value
,Adds an entry if the entry does not exist, else modifies the
existing entry.
my_dict['John'] = 'B+'
del my_dict[key]
Deletes the key entry from a dict.
del my_dict['John']
key in my_dict
Tests for existence of key in my_dict
if 'John' in my_dict: # ...
dict methods - correct answer my_dict.clear()
Removes all items from the dictionary
my_dict = {'Bob': 1, 'Jane': 42}
my_dict.clear()
print(my_dict)
{}
my_dict.get(key, default)
Reads the value of the key entry from the dict. If the key does not
exist in the dict, then returns default.
my_dict = {'Bob': 1, 'Jane': 42}
print(my_dict.get('Jane', 'N/A'))
print(my_dict.get('Chad', 'N/A'))
42
, N/A
my_dict1.update(my_dict2)
Merges dictionary my_dict with another dictionary my_dict2.
Existing entries in my_dict1 are overwritten if the same keys
exist in my_dict2.
my_dict = {'Bob': 1, 'Jane': 42}
my_dict.update({'John': 50})
print(my_dict)
{'Bob': 1, 'Jane': 42, 'John': 50}
my_dict.pop(key, default)
Removes and returns the key value from the dictionary. If key
does not exist, then default is returned.
my_dict = {'Bob': 1, 'Jane': 42}
val = my_dict.pop('Bob')
print(my_dict)
{'Jane': 42}
Underlying data structures: Binary search tree, Hash table -
correct answer Set, Dictionary(Map)
Underlying data structures: Heap - correct answer Priority
queue
Underlying data structures: Linked list, Array - correct
answer Bag, Queue, List