Year 11 - Computing
Writing to text files
Programming: dictionaries and data files
Study Hub
This pupil-friendly study guide includes a unit summary, clear notes, common mistakes, and quick questions with answers.
Year 11 - Computing
Programming: dictionaries and data files
This unit introduces pupils to the new data structures of records and dictionaries. They will develop a Caesar cipher encryption program using a dictionary as a cipher wheel. Pupils will explore how data can be read from and written to files and how this data can be used within a program.
You will learn to write data to a new file and append data to an existing text file.
There are different modes for opening a file, r (read), w (write) and a (append). When you open a file in write mode, it creates a new file. If the file already exists then the file will be overwritten.
a file handling mode that allows a program to write data to a file, where, if the file does not exist, a new file is created, and if the file already exists, the content is overwritten. Add one real device or system example to prove understanding.
Mistake: You have to create a new write() line for each line you want to add to a file. Correction: You can write mutiple lines in one write() statement. But if you want the text to appear on separate lines, you must use the new line character.
Browse all guides in the Year 11 Computing guide library.