Q1: dict
objects are well-suited to model discrete mathematical functions and to approximate continuous ones. What property of dictionaries is the basis for that claim, and how does it relate to functions in the mathematical sense?
< your answer >
Q2: Explain why hash tables are a trade-off between computational speed and memory usage!
< your answer >
Q3: The dict
type is an iterable that contains a finite number of key-value pairs. Despite that, why is it not considered a sequence?
< your answer >
Q4: Whereas key look-ups in a dict
object run in so-called constant time (i.e., extremely fast), that does not hold for reverse look-ups. Why is that?
< your answer >
Q5: Why is it conceptually correct that the Python core developers do not implement slicing with the []
operator for dict
objects?
< your answer >
Q6: Memoization is an essential concept to know to solve problems in the real world. Together with the idea of recursion, it enables us to solve problems in a "backwards" fashion effectively.
Compare the recursive formulation of fibonacci()
in Chapter 9 , the "Easy at second Glance" example, with the iterative version in Chapter 4
, the "Hard at first Glance" example!
How are they similar and how do they differ? Also consider how the flow of execution behaves when the functions are being executed.
< your answer >
Q7: How are the set
and the dict
types related? How could we use the latter to mimic the former?
< your answer >
Motivate your answer with one short sentence!
Q8: We may not put dict
objects inside other dict
objects because they are mutable.
< your answer >
Q9: Mutable objects (e.g., list
) may generally not be used as keys in a dict
object. However, if we collect, for example, list
objects in a tuple
object, the composite object becomes hashable.
< your answer >
Q10: Mutability of a dict
object works until the underlying hash table becomes too crowded. Then, we cannot insert any items any more making the dict
object effectively immutable. Luckily, that almost never happens in practice.
< your answer >
Q11: A dict
object's .update() method only inserts key-value pairs whose key is not yet in the
dict
object. So, it does not overwrite anything.
< your answer >
Q12: The set
type is both a mapping and a sequence.
< your answer >