Starter quiz
- What is a list in Python?
- a single-value data type
- a type of loop
- a function to perform calculations
- a collection of data in a particular sequence ✓
-
- Match the terms with their definitions.
- string⇔a collection of characters ✓
- mutable⇔able to be changed ✓
- index⇔the location of an item in a list ✓
- What is the index number that holds the first item in a Python list?
- -1
- 0 ✓
- 1
- 2
-
- What method would you use to add an item to a list?
- `remove()`
- `sort()`
- `append()` ✓
- `index()`
-
- What is the term for repeating a sequence of instructions?
- 'iteration' ✓
- Which loop is used for count-controlled iteration?
- 'for' ✓
Exit quiz
- Match the terms with their definitions.
- operator⇔a symbol or word that instructs the computer to perform a calculation ✓
- list⇔a collection of data in a sequence ✓
- shuffle⇔randomly reorder the contents of a list ✓
- string⇔a collection of characters ✓
- immutable⇔not able to be changed ✓
- What is the primary purpose of a for loop in Python?
- to execute code indefinitely
- to repeat a block of code a specific number of times ✓
- to handle errors in code
- to define variables
-
- What is the index of the second item in a list?
- '1' ✓
- What can be used to perform calculations in Python?
- variables
- operators ✓
- loops
- strings
-
- Which statement about performing mathematical operations on list items in Python is true?
- Items must be copied to a new variable first.
- Operations are only for lists with numbers.
- Operations can be performed directly on list items. ✓
- Items need to be converted to strings for operations.
-
- What does the `shuffle()` function do to a list in Python?
- sorts the list in ascending order
- reverses the order of the list
- randomly reorders the list items ✓
- removes duplicates from the list
-
Worksheet
Loading worksheet ...
Presentation
Loading presentation ...
Video
Lesson Details
Key learning points
- Mathematical operations can be performed using operators in Python.
- Mathematical operations can be performed on individual list items.
- The shuffle() function can be used to randomly reorder the contents of a list.
Common misconception
Mathematical operations cannot be performed on items held in a list; the items must first be stored in a new variable.
Mathematical operations can be performed directly on list items by using an index value to reference the value used.
Keywords
Operator - a symbol or word that instructs the computer to perform a specific calculation or action
List - a collection of data in a particular sequence
+