Starter quiz
- ______ is used when there is more than one possible path for a program to follow.
- 'selection' ✓
- Match the keyword to the definition.
- selection⇔used when there is more than one possible path for a program to follow ✓
- list⇔a collection of data in a particular sequence ✓
- data structure⇔an organised way to store data for easy use ✓
- index⇔the location of an item or element in a list or string ✓
- What is the correct way to access the first item in a list called names?
- `names[0]` ✓
- `names[1]`
- `names{0}`
- `names(0)`
- `names(1)`
-
- What letter can you type in to join text and the values held by a variable in a print statement?
- j
- c
- f ✓
- p
-
- What is an IndexError?
- when you have too many items in a list
- when you refer to an index that does not exist in a list ✓
- when you have too few items in a list
- when you have two of the same index values in a list
-
- A list is a d______ data structure that can grow or shrink as you add or remove items.
- 'dynamic' ✓
Exit quiz
- Which list method can be used to add an item to the end of a list?
- `list.insert()`
- `list.add()`
- `list.append()` ✓
- `list.remove()`
-
- Which list method can be used to remove the last item from a list if you do not know the index of the last item?
- `list.pop()` ✓
- `list.remove()`
- `list.delete()`
- `list.append()`
-
- The operation `list.sort(reverse=True)` sorts a list in ______ order
- 'descending' ✓
- What list method is used to find the index of a specific item?
- `list.find(item)`
- `list.search(item)`
- `list.index(item)` ✓
- `index.find(item)`
-
Worksheet
Loading worksheet ...
Presentation
Loading presentation ...
Video
Lesson Details
Key learning points
- List methods can be used to perform operations on lists such as to add, remove and insert items.
- A list is a dynamic data structure, meaning the length of a list is the number of values it currently stores.
- A list can be sorted using a list method to aid processing.
Common misconception
Once an item is added to a list it is fixed in to the structure of the list and it cannot be altered.
Items can be removed, inserted and amended in a list using list methods. These methods change the structure of the list. Values of items can also be updated.
Keywords
Append - adding to an existing data structure
Remove - taking an item away from an existing data structure
Sort - putting items in a particular order
List method - a built-in function that will perform an operation on a list
+