Starter quiz
- The data a variable holds can ______ throughout the running of a program.
- change ✓
- not change
-
- The `=` symbol in Python is used for...
- assignment. ✓
- equations.
- comparison.
-
- Which of the following is an example of a string?
- `100`
- `True`
- `3.14`
- `"Hello world!"` ✓
-
- What name would be displayed when this Python program is run? ```name = "Izzy" name = "Lucas" name = "Izzy" print (name)```
- `name`
- `Izzy` ✓
- `Lucas`
-
- What is the result of the following Python expression? ```10 + 5 * 2```
- '20' ✓
- What function is used to convert user input from a string to an integer in Python?
- `input()`
- `print()``
- `int(input())` ✓
- `int()`
-
Exit quiz
- Write the Python code to store the number 25 in a variable called age.
- 'age = 25' ✓
- In Python, which keyword allows you to create a block of code that only executes when a certain condition is true?
- `print`
- `else`
- `if` ✓
- `input`
-
- In Python, which of the following code blocks demonstrates a correct way to use an if-else statement?
- 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:`
-
- You are creating a program for a game where the player wins if they roll a 6 on a dice. Write the if statement that would check if the variable `dice_roll` is equal to 6.
- 'if dice_roll == 6:' ✓
Worksheet
Loading worksheet ...
Presentation
Loading presentation ...
Video
Lesson Details
Key learning points
- Selection is used when there is more than one possible path for a program to follow.
- Relational operators can be used to compare the values of expressions.
- Expressions formed using relational operators evaluate to either True or False.
- Logical expressions can be built using a combination of relational and logical operators.
Common misconception
The = symbol is used to check if a variable is equal to a value (comparison).
The = symbol is used in Python for assignment. The == operator is used for comparison.
Keywords
Relational operators - compare two values and produce the result of True or False
Condition - an expression that evaluates to True or False
Selection - used when there is more than one possible path for a program to follow
Logical expression - an expression that combines relational and logical operators
+