- describe which containers are mutable and which are immutable
- use methods from each container type to efficiently manipulate a list
- identify a specific use case for each container type
Chapter 3, pages 65-75
-
mutability
-
duck typing
-
containers - iterable
-
lists
- notation
- indexing & slicing like strings
- slicing on LHS of assignment
- del slice
- list operators:
- NOT mathematical arrays
- list methods:
- append, count, insert, remove, clear, extend, reverse, index, pop, sort
- testing
- devise a way to test each function
- reference counting
- use cases
- order matters
- mutable
-
tuples - immutable lists
- notation
- immutable structure
- may have mutable members
- what methods exist?
- test how lists are different from tuples
- use cases
- order matters
- immutable
-
sets - unordered lists with max one of each thing
- notation
- items in set must be immutable
- test addition of things to sets vs lists
- test methods:
- difference vs difference_update vs symmetric_difference
- use cases
- collect unique list of things
-
dictionaries - powerful container type
- notation
- keys must be immutable
- values can be anything - including other containers
- explore methods
- use what you've learned to hypothesis how they work and test those hypotheses