Python Reading
- Read the chapter entitled Lists
from section "Lists" through section "Cloning Lists".
Key Ideas
- A list is an ordered collection of items that can be of
any type, e.g. ["Joy and Beauty of Data", 2017].
- List creation
- row_1 = ["Jerico", "Riley", "Anna", "Jessica"]
- row_2 = ["Leah", "Nick", "Amber", "Cory"]
- rows = [row_1, row_2]
- Determining List Length: len
- Accessing List Elements
- List Membership: in and not in
- List Concatenation: +
- List Repetition: *
- List Slices
- row_1[2:4]
- row_1[:2]
- row_1[2:]
- Lists are mutable (unlike Strings)
- Replacement: row_1[0] = "Morgan"
- Deletion: row_1[1:3] = []
- Deletion: del(row_1[0])
- Insertion: row_2[2:2] = ["Logan", "Daniel", "Dyllan"]
- List Aliasing: row_1 = row_2
- List Cloning: row_1 = row_2[:]
Active Learning
Work the following exercises:
- Exercise 14
- Exercise 15
- Exercise 17