GCSE Computer Science (Pearson IGCSE)

Topic Summaries

ALGORITHMS AND PROGRAMMING: Programming techniques

File handling

Operation Description Python example
Open Open a file (in r = read mode, w = write mode, or a = append mode) file = open(“data.txt”, “r”)
Read Read content from a file data = file.read() or file.readline()
Write Write to a file (overwrites)

file = open(“data.txt”, “w”)

file.write(“Hello”)

Close Closes the file file.close()

Unlock File handling

Sign up to unlock the rest of this topic — plus every other topic, video, flashcard set and eBook guide in your SnapRevise Digital subscription.

Cancel anytime — instant access the moment you sign up.