Back to Programming Concepts

Oak National Academy

Lessons written by expert teachers in England, each with slides, a video and quizzes.

Their topic:
Programming: iteration · Programming: selection
For your topic:
Programming Concepts · Computer Science - 9210

Use these lessons alongside our lesson note, which covers your syllabus in full.

What this covers in your syllabus

3 lessons from Oak National Academy

Lesson 1 of 3 · GCSE level, ages 14 to 16

Nested loops

By the end: I can create programs that use nested loops to solve problems.

Key learning points

  1. Nested loops involve placing one loop inside another.
  2. The outer loop controls how many times the inner loop repeats.
  3. Each time the outer loop is repeated, the inner loops are re-entered and started again as if new.

Keywords

nested loop
the process of placing one loop inside another loop
outer loop
the loop that contains another loop inside it
inner loop
the loop that is placed inside another loop and runs completely each time the outer loop runs once

A common mistake

Mistake: Learners may think that the inner loop only runs once per program, rather than repeating fully each time the outer loop runs.

In fact: The inner loop runs completely every time the outer loop runs once. This means the code inside the inner loop is repeated multiple times depending on how many times the outer loop is executed.

Check what you learned

From Oak National Academy's exit quiz. Choose every answer that is right.

What is a nested loop?
What happens to the inner loop when the outer loop runs again?
Which of these is an example of a nested loop?
What is the purpose of a nested loop?
What happens if the outer loop in a nested loop has a range of 0?

A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0. Read the licence

Lesson 2 of 3 · GCSE level, ages 14 to 16

Nested selection

By the end: I can trace and modify code in a program that uses nested selection.

Key learning points

  1. Selection statements with conditions can be nested inside another selection statement.
  2. Nested selection statements are used to implement complex branching logic.
  3. If a condition of a main selection block evaluates to True, it leads to sub-conditions which are inside the main block.

Keywords

nested selection
a block of code where a selection block is placed within another selection block

A common mistake

Mistake: A nested selection statement can only have one nested selection block.

In fact: Selection statements can can continue to be nested in further selection blocks to provide more complex conditions for which specific code will be executed.

Check what you learned

From Oak National Academy's exit quiz. Choose every answer that is right.

What is nested selection in programming?
What does the `lower()` method do when used on a string in Python?
What would be displayed if the user enters "Jun" for the username?
What would be displayed if the user enters "Izzy" for the username and then "Dog1234" for the password?
What would be displayed if the user enters "Izzy" for the username and then "Fish4321" for the password?

A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0. Read the licence

Lesson 3 of 3 · GCSE level, ages 14 to 16

While loops

By the end: I can use iteration controlled by a condition to repeat sequences of code.

Key learning points

  1. Computer programs use iteration to repeat sequences of instructions.
  2. Iteration can be controlled by a condition that determines if the instructions should be repeated.
  3. In Python, condition-controlled iteration is implemented using the 'while' loop command.

Keywords

iteration
the process of repeating a sequence of instructions within a program loop
condition
an expression that evaluates to True or False

A common mistake

Mistake: A loop will always run at least once.

In fact: A loop only runs if the condition allows it. If the condition isn’t met initially, the code inside won’t run at all.

Check what you learned

From Oak National Academy's exit quiz. Choose every answer that is right.

What is iteration in programming?
What does a condition in a while loop do?
What happens if the condition in a while loop is False initially?

A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0. Read the licence

The wording comes from each publisher. The layout and the links to your syllabus are ours.