Starter quiz
- In Python, which keyword allows you to create a block of code that only executes when a certain condition is true?
- 'if' ✓
- Which `if` statement would correctly check if the variable score is greater than or equal to 80?
- `if score >= 80:` ✓
- `if score > 80:`
- `if score = 80:`
- `if score <= 80:`
-
- Which of the following is correct when describing nested `if` statements?
- The first condition needs to be `False` before the next condition can be run.
- The first condition needs to be `True` before the next condition can be run. ✓
-
- The `=` symbol in Python is used for ...
- equations.
- assignment. ✓
- comparison.
-
- What keyword is used in Python to output text to the user?
- 'print' ✓
- S______ is used when there is more than one possible path for a program to follow.
- 'Selection' ✓
Exit quiz
- What is the purpose of an `elif` statement in Python?
- to create a loop
- to define a function
- to handle multiple conditions in a selection statement ✓
-
- What is the correct syntax for creating a list in Python?
- {“Monday”, “Tuesday”, “Wednesday”}
- [“Monday”, “Tuesday”, “Wednesday”] ✓
- (Monday, Tuesday, Wednesday)
-
- What type of data structure is a list in Python?
- static
- dynamic ✓
-
- Each item within the list is referred to by an ______, which is its position in the list.
- 'index' ✓
- What will the following code print? ```days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] print(days[3])```
- Wednesday
- Thursday ✓
- IndexError
- Tuesday
-
- What will the following code print? ```days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] print(days[7])```
- Saturday
- Sunday
- IndexError ✓
-
Worksheet
Loading worksheet ...
Presentation
Loading presentation ...
Video
Lesson Details
Key learning points
- Lists are data structures that can store multiple related items in Python.
- Values held in a list are ordered by index number, with the first item in the list being stored at index [0].
- List items can be directly accessed by specifying the index value.
Common misconception
A list index starts at 1 as that is the first element in the list and should be counted as the first item.
In most programming languages, list indexing is zero-based, which means the index starts at 0. The number indicates the position before the value is seen.
Keywords
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
+