Boolean logic in programs – OCR GCSE Computer Science lesson (J277)
Pupils learn to write Python conditions with AND, OR and NOT that match a rule, and use a truth table to test them.
Lesson 10 of 11 in unit 10.3 Binary, Boolean Logic and Iteration, taught in Year 10, Spring 1. It answers one big question: How do logic gates show up in the code we write?
By the end, pupils can write Python conditions with AND, OR and NOT that match a rule, and use a truth table to test them.
- The Build (the main task)
- Write a Python program for the smart heating that inputs the temperature and whether anyone is home (Y or N), and applies Boolean logic to print 'Heating on' if it is below 18 °C and someone is home, or if it is below 3 °C; otherwise 'Heating off'.
- Support version
- Part-filled code: the inputs and print lines are written; pupils complete the condition from a bank of parts (temp < 18, home == "Y", temp < 3, and, or, brackets).
- Challenge
- Complete a truth table for the heating condition and use it to choose four test values that check every outcome.
- Real-world link
- The smart heating decides for itself when to switch on – including a frost guard when no one is home.
- Key words
- Boolean logic, Boolean operator and Apply, each with a definition, an icon and a common mix-up on the key vocabulary slide.
- Misconceptions it tackles
- “OR is False when both sides are True”; “home == "Y" or "y" checks for either letter”.
- OCR J277 specification
- 2.4.1 (boolean logic: AND, OR and NOT gates, their symbols and truth tables; logic diagrams and Boolean expressions with up to three inputs; applying logical operators in programs); 2.2.1 (programming fundamentals: iteration – count-controlled loops (FOR) and condition-controlled loops (WHILE, DO UNTIL); Boolean operators in conditions).
Every lesson follows the same Code & Commerce structure: a Bell Task recall starter, key vocabulary with definitions and icons, short teaching chunks with a check before pupils move on, The Build (one main task), challenge questions that get harder, and an exit question. Answers reveal one at a time on the slides, and everything is editable PowerPoint and Word.
Pupils need computers for the main task.
Also sold in the Binary, Boolean Logic and Iteration unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.
What's included
- Slide deck (PowerPoint)
- Lesson plan (Word)
- Worksheet (Word)
- Support worksheet with scaffolds (Word)
- Boolean logic in programs - Quiz Quiz Trade Cards
- Single-teacher licence: use and adapt it with your own classes
More for GCSE Computer Science (OCR)
See allPupils learn to order the units of data from bit to petabyte and convert between them, stating why all data is stored in binary.
Free sample lessonPupils learn to trace and write FOR loops that use range() with a start, stop and step, and use the loop variable inside the loop.
Pupils learn to convert between denary numbers from 0 to 255 and 8-bit binary using place values.
Written for the specifications named. Not endorsed by or affiliated with any exam board.