Programming · 4 question types
Past paper frequency (2018 to 2024)
This topic accounts for approximately 3% of your exam marks.
OPENFILE, READFILE, WRITEFILE, CLOSEFILE pseudocode operations appear occasionally.
CIE pseudocode uses a small set of dedicated keywords for file operations.
| Operation | Pseudocode | Python equivalent |
|---|---|---|
| Open for a given mode | OPENFILE "filename.txt" FOR <mode> | file = open("filename.txt", "r") (or "w", "a") |
| Read one line | READFILE "filename.txt", LineVariable | line = file.readline() |
| Write one line | WRITEFILE "filename.txt", TextToWrite | file.write("text\n") |
| Close the file | CLOSEFILE "filename.txt" | file.close() |
The CIE file commands always include the filename so the operation knows which file it is acting on.