You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Programs often need to store data permanently — after the program closes, the data should still be available the next time it runs. File handling allows programs to read from and write to text files. This is a key topic for GCSE Computer Science (AQA 3.2 / OCR J277 2.2).
Variables only exist while a program is running. When the program ends, all variable data is lost. Files provide persistent storage — data saved to a file remains available after the program closes.
Common uses of file handling:
There are three main file operations:
| Operation | Description | Pseudocode | Python mode |
|---|---|---|---|
| Read | Opens a file and reads its contents | OPENREAD | "r" |
| Write | Creates a new file (or overwrites existing) and writes data | OPENWRITE | "w" |
| Append | Opens an existing file and adds data to the end | OPENAPPEND | "a" |
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.