Unit bundle · Key Stage 3

Python: Iteration and Boolean Operators – Year 8 Computing lessons

Six Year 8 Python lessons: elif, AND, OR and NOT, for and while loops, debugging and test plans, building a password checker.

Also in a bundle Year 8 Computing – a full year of KS3 lessons 36 lessons for £89 · save 38% on buying separately

In Year 7 pupils wrote their first Python programs with input, variables and if/else. This unit makes those programs do real work: combining tests with elif, AND, OR and NOT, repeating code with for and while loops, and then proving the program works with a planned, systematic test. Pupils build up a password-strength checker one lesson at a time and finish by testing it like a software tester, so they can explain how a program makes decisions and repeats checks for us.

Unit 8.1 is taught in Year 8, Autumn 1, and answers one big question: How can loops and logic make a program check things for us? Every lesson uses the same real-world context (automating repetitive checks), and pupils make a password-strength checker. The careers link is a software tester: a software tester plans checks before a program is released, runs them with normal and tricky data, and reports logic errors to the developers – exactly what pupils do to their password checker in lesson 5.

What happens in each lesson:

Lesson 1, Recap: input, variables and if: Why does Python need to know what type our data is? Main task: write a sign-up program that asks for a username and an age, casts the age to an integer and uses if/else to say whether the user is old enough (13 or over) to make an account.

Lesson 2, elif, AND, OR and NOT: How can a program make a decision from more than one test? Main task: write a program that rates a password as Weak, OK or Strong, using if, elif and else and at least one AND, OR or NOT in a condition.

Lesson 3, Count-controlled loops (for): How can a program repeat something a fixed number of times? Main task: write a program that uses a for loop to look at every character of a password, increments a counter for each digit, then prints how many digits it has.

Lesson 4, Condition-controlled loops (while): How can a program keep repeating until something changes? Main task: write a program that keeps asking the user for a new password while it is shorter than 8 characters, counts the attempts, then says how many tries it took.

Lesson 5, Debugging and test plans: How do we prove a program works? Main task: complete a test plan for the password checker (test data, reason and expected result), run each test, record the actual result and fix the two logic errors it finds.

Lesson 6, Progress Check: 16-question check: 15 multiple-choice questions + one applied question.

Misconceptions it tackles include
“If the user types digits, input() gives Python a number”; “OR is only True when both tests are True”; “range(1, 5) counts 1, 2, 3, 4 and 5”. Each is planned into a hinge question before the main task or an exit question, so you find out who still holds it.

National Curriculum coverage (KS3 computing programme of study): NC3, two or more languages, at least one textual; data structures; modular programs with procedures or functions; NC4, boolean logic (AND, OR, NOT) in circuits and programming; binary numbers, addition and conversion.

It builds on 7.6 Introduction to Python (print, variables, input, data types, if/else and comparison operators); 7.2 Algorithms and Block Programming (loops and selection in blocks); 7.1 Online Safety (what makes a strong password). It leads on to 8.2 Boolean Logic and Circuits (AND, OR and NOT as logic gates and truth tables), 8.6 Physical Computing (loops and selection on a micro:bit), 9.1 Python: Lists and Functions (looping through lists) and 9.2 Searching and Sorting.

Adapting it for your school
Works in any Python 3 editor: IDLE, Thonny, or a free online editor that runs input(). Lesson 1 is a flex lesson: if 7.6 was taught recently, fold its casting example into the Bell Task of lesson 2. If the computers are not available, use the unplugged slide and printed trace tables: the learning is the same. Swap the password checker for another check your pupils care about, such as a username or a quiz-answer checker; the code patterns stay the same.

Two versions in one download. The "With quiz" folder is for schools with a Code & Commerce Quizzes subscription: wherever the lessons use a Progress Check, its multiple-choice questions are ready-made on the quiz site for you to set, with a printed version as the backup. The "Without quiz" folder is the same teaching for standalone use, with no mention of the quiz site and every check on paper. You don't need a quiz subscription to use it.

What's included

  • 6 lesson slide decks (PowerPoint)
  • 6 lesson plans (Word)
  • 6 worksheets, plus 5 support versions with scaffolds (Word)
  • Medium term plan with intent, key words, misconceptions and adaptive teaching notes (Word)
  • Progress Check lesson to assess the unit, with an applied question
  • Debugging and test plans - Quiz Quiz Trade Cards
  • Department licence: every teacher in your department can use and adapt it
  • Two versions of the files: one for Code & Commerce Quizzes subscribers and one for standalone teaching, no quiz site needed

In this bundle

Worth £24 bought separately at £4 a lesson. The bundle saves you 16%.

More for KS3 Computing

See all

Written for the specifications named. Not endorsed by or affiliated with any exam board.