Subtopic Notes

8.3 - File handling

8. Programming

File Handling

  • Text files consist of lines of text that are read or written consecutively as strings
  • The purpose of storing data in a file is to be used again by a program
  • Data in files are stored permanently, meaning they can be used later
  • It is good practice to explicitly open a file, stating the mode of operation, before reading from or writing to it.
  • File can be opened in two modes:
    • READ: for data to be read from the file
    • WRITE: for data to be written to the file. A new file will be created and any existing data in the file will be lost
  • A file should be opened in only one mode at a time

PYTHON

Python can be executed directly in the browser.

Editor — Python
Output
No output yet.

PSEUDOCODE

Pseudocode uses basic Cambridge-style keyword highlighting. Execution is not supported yet.

Editor — Pseudocode