Year 7 · Computing · Python: first programs · Lesson 4
Selection with if and else
Selection in Python with if and else, conditions, comparison operators (==, !=, >, <, >=, <=), and the difference between = and ==.

17-minute video lesson
Teaching, worked examples and 20 practice questions solved step by step.
Watch free for a monthWhat your child will learn
- Explain selection
- Write if/else statements
- Use comparison operators
- Predict program output
The method
- if condition:
- Indent True code.
- else:
- == not =.
Key words: selection, if, else, condition, comparison operator, indentation.
Worked examples
The first three practice questions from the lesson, with every step.
Question 1
What is selection?
- Step 1: Decision
Answer: making a decision about which code to run
Question 2
Which keyword starts a decision?
- Step 1: i...
Answer: if
Question 3
Which keyword runs when the condition is False?
- Step 1: e...
Answer: else