Exercises
In addition to enhancing the examples in this chapter, there are many other exercises:
- Create a
SortedDict
collection that takes akeyfunc
to decide the sort order. - Create a
SortedList
collection that hasO(log(n))
inserts and always returns a sorted list during each iteration. - Create a Borg pattern that has a state per subclass.
Example answers for these exercises can be found on GitHub: https://github.com/mastering-python/exercises. You are encouraged to submit your own solutions and learn about alternative solutions from others.