1/57
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No study sessions yet.
List definition
An ordered collection of items stored in one variable
Python list indexing starts at
0
AP pseudocode list indexing starts at
1
Python first element index
0
AP pseudocode first element index
1
Python last element index
len(list) - 1 or -1
AP pseudocode last element index
length(list)
Python create a list
my_list = [1, 2, 3]
AP pseudocode create a list
myList ← [1, 2, 3]
Python access element at index i
my_list[i]
AP pseudocode access element at position p
myList[p]
Python update element
my_list[i] = value
AP pseudocode update element
myList[p] ← value
Python append
my_list.append(value)
AP pseudocode append
APPEND(myList, value)
Python insert
my_list.insert(i, value)
AP pseudocode insert
INSERT(myList, position, value)
Python remove by index
mylist.pop(i) or del mylist[i]
AP pseudocode remove
REMOVE(myList, position)
Python remove by value
my_list.remove(value)
AP pseudocode remove by value
Must loop and remove when found
Python list length
len(my_list)
AP pseudocode list length
length(myList)
Python for-each loop
for item in my_list:
AP pseudocode for-each loop
FOR EACH item IN myList
Python index loop
for i in range(len(my_list)):
AP pseudocode index loop
FOR i ← 1 TO length(myList)
Python slicing
my_list[start:end]
AP pseudocode slicing
Not supported
Check if value in Python list
value in my_list
Check if value in pseudocode
Loop and compare each item
Filtering definition
Creating a new list with selected items
Python filtering example
if condition: new_list.append(x)
Pseudocode filtering example
IF condition THEN APPEND(newList, x)
Accumulator pattern definition
Looping to build a total or count
Python accumulator
total += item
Pseudocode accumulator
total ← total + item
Python find min/max
min(list), max(list)
Pseudocode find min/max
Compare each item in a loop
Combining Python lists
new = list1 + list2
Combining pseudocode lists
Use APPEND in a loop
Parallel lists definition
Two lists where item positions match
Nested lists definition
Lists inside lists (matrix[row][col])
Python nested list access
matrix[r][c]
Pseudocode nested list access
matrix[r][c]
List mutation definition
Changes the list itself (append, remove)
List reassignment definition
Creates new list and reassigns variable
Python negative indexing
Allowed (e.g., list[-1])
Pseudocode negative indexing
Not allowed
Python common list methods
append, insert, pop, remove, sort, reverse, count, index
AP pseudocode list commands
APPEND, INSERT, REMOVE, length, list[position]
Off-by-one error definition
Mistake from starting at wrong index
Python loop range rule
0 to len(list)-1
Pseudocode loop range rule
1 to length(list)
APPEND meaning
Add to end of list
INSERT meaning
Add value at a specific 1-based position
REMOVE meaning
Delete item at given position
length(list) meaning
Number of items in list