Lesson Plan

Lesson Plan
Grade: Date: 17/01/2026
Subject: Computer Science
Lesson Topic: Show understanding of an exception and the importance of exception handling
Learning Objective/s:
  • Describe what an exception is and why it occurs during program execution.
  • Explain the purpose and benefits of exception handling in file processing.
  • Identify and apply the try‑except‑else‑finally structure in Python code.
  • Demonstrate how to handle specific file‑related exceptions and create a custom exception.
  • Evaluate best‑practice guidelines for robust exception handling.
Materials Needed:
  • Projector or interactive whiteboard
  • Python IDE (e.g., IDLE, VS Code)
  • Sample text files for reading/writing
  • Printed handout of exception‑handling flowchart
  • Worksheet with error‑handling exercises
  • Internet access for documentation lookup
Introduction:

Start with a quick poll: who has ever seen a program crash because a file was missing? Review prior knowledge of runtime errors and explain that today’s success criteria are to define exceptions, illustrate the try‑except‑else‑finally pattern, and apply it to a real file‑reading task.

Lesson Structure:
  1. Do‑now (5’) – short quiz on common runtime errors and their symptoms.
  2. Mini‑lecture (10’) – define an exception, discuss why handling matters, and list benefits.
  3. Guided demo (12’) – walk through a Python try‑except‑else‑finally example; run code and observe outcomes.
  4. Pair activity (15’) – modify a provided script to catch FileNotFoundError and PermissionError, then test with deliberately faulty files.
  5. Custom exception task (8’) – introduce a user‑defined InvalidRecordError class; students add simple validation to the script.
  6. Whole‑class debrief (5’) – review the best‑practice checklist and discuss common pitfalls.
Conclusion:

Recap the key steps of robust exception handling and ask each group to write one “take‑away tip” on a sticky note as an exit ticket. For homework, students will refactor a larger file‑processing program to incorporate the patterns learned today.