| Lesson Plan |
| Grade: |
Date: 05/03/2026 |
| Subject: Computer Science |
| Lesson Topic: Understand why data is stored in external files and how programs can access them |
Learning Objective/s:
- Describe the reasons for storing data in external files, including persistence, size limitations, sharing, backup, and security.
- Differentiate between text and binary files and select appropriate file types for given tasks.
- Explain the four basic file operations (open, read, write, close) and the common access modes (r, w, a, r+, w+, a+).
- Compare sequential and random access and choose the suitable method for a specific data set.
- Write and run simple code (pseudocode or Python) that opens, reads/writes, and closes a file correctly.
|
Materials Needed:
- Projector and screen for slides
- Whiteboard and markers
- Computers with a Python IDE installed
- Sample text file (students.txt) and a log file
- Handout summarising file modes and operations
- Worksheet with file‑handling exercises
|
Introduction:
Begin with a quick discussion: ask students where they think a program keeps its data after it stops running. Recall prior learning about variables and memory limits, then introduce today’s success criteria – students will be able to explain why external files are needed, identify file types and modes, and demonstrate basic file handling in code.
|
Lesson Structure:
- Do‑now (5') – Students list ways a program could lose data if it only used internal memory.
- Mini‑lecture (10') – Present reasons for external storage, file types, and core file operations with examples.
- Live demonstration (10') – Show Python code opening, appending to, and closing a log file; discuss each access mode.
- Guided practice (15') – In pairs, students write pseudocode to update a student record using the “r+” mode while the teacher circulates.
- Interactive quiz (5') – Quick Kahoot/exit poll on sequential vs random access and correct mode selection.
- Consolidation (5') – Review key points, answer questions, and clarify common errors (e.g., using “w” unintentionally).
|
Conclusion:
Summarise that external files provide persistence, sharing, and efficient handling of large data, and that using the correct mode and always closing a file are essential practices. For the exit ticket, ask each student to write one file mode and its appropriate use. Homework: complete the worksheet by implementing a Python script that reads a text file and writes a summary report.
|