Choose exam board for KS4 Computer Science (GCSE)
Choose exam board for KS4 English
Choose exam board for KS4 French
Choose exam board for KS4 Geography
Choose exam board for KS4 German
Choose exam board for KS4 History
Choose tier for KS4 Maths
Choose exam board for KS4 Music
Choose exam board for KS4 Physical education (GCSE)
Choose exam board for KS4 Religious education (GCSE)
Choose exam board for KS4 Spanish

      Building a program using control structures

      Lesson details

      Learning outcome

      I can combine sequence, selection and iteration to build a program that uses complex conditions.

      Key learning points

      1. Expressions formed using logical operators evaluate to either True or False.
      2. Logical and relational operators can be combined to create complex conditions.
      3. The programming constructs of sequence, selection and iteration can be combined to make more complex programs.

      Keywords

      • Condition - an expression that evaluates to True or False

      • Selection - used when there is more than one possible path for a program to follow

      • Iteration - the process of repeating a sequence of instructions within a program loop

      Common misconception

      Learners often get confused between the logic operators AND and OR.

      For an AND statement to return True both inputs must be True. For an OR statement to return True either input can be True.

      Teacher tip

      The final activity for this lesson is broken down into three stages, which get progressively more challenging to solve. Some pupils may only achieve the first stage but will still have had the opportunity to implement some of the skills and knowledge they have developed over the unit.

      Equipment

      Pupils will need access to a device that can edit and run Python programs. Examples in this lesson use the RPF Code Editor https://oak.link/python-editor

      Licence

      This content is © Oak National Academy Limited (2026), licensed on Open Government Licence version 3.0
      except where otherwise stated. See Oak's terms & conditions
      (Collection 2).

      Lesson video

      Loading...

      Prior knowledge starter quiz

      6 Questions

      Q1.
      What is the term for repeating a sequence of instructions multiple times in a program?

      selection
      Correct answer: iteration
      condition
      randomisation

      Q2.
      In Python, which code is used to create a loop that repeats as long as a condition is True?

      if
      for
      Correct answer: `while`
      else

      Q3.
      What operator should be added to the gap to make the while loop run whilst the name entered is not equal to Sam?
      1
      while name {operator here} "Sam":
      Code colour

      ==
      =
      Correct answer: !=
      >=

      Q4.
      What is the primary purpose of a flag in programming?

      to store a numerical value
      Correct answer: to indicate whether a specific condition has been met
      to perform mathematical calculations
      to display output on the screen.

      Q5.
      In a game, a player earns bonuses for collecting a certain number of coins. Which of the following would most likely cause a flag named bonus_earned to be set to True?

      The player loses a life.
      Correct answer: The player collects a set number of coins.
      The player quits the game.
      The player completes a level.

      Q6.
      A flag can have two states and False.

      Correct Answer: True, true

      5 Questions

      Q1.
      Which logical operator in Python would you use to check if at least one of two conditions is True?

      and
      Correct answer: `or`
      not
      ==

      Q2.
      Which logical operator in Python would you use to check if both of two conditions are True?

      Correct answer: `and`
      or
      not
      =

      Q3.
      Which of these Python while loop conditions will keep the loop running forever, no matter what happens inside the loop?

      while count < 10:
      while user_input != "quit":
      Correct answer: `while True:`
      while not game_over:

      Q4.
      Which of the following is a potential benefit of combining programming structures?

      Correct answer: creating more complex programs
      Correct answer: making code more concise and efficient
      Correct answer: solving a wide range of problems
      there is no need for variables

      Q5.
      What is the output of the following Python code?
      1234567
      is_weekend = True have_homework = False if is_weekend and not have_homework: print("Time to relax") else: print("Time to study.")
      Code colour

      Correct answer: Time to relax
      Time to study
      An error message will occur.
      No output will be produced.

      To help you plan your 8 computing lesson on: Building a program using control structures, download all teaching resources for free and adapt to suit your pupils' needs...