PROGRAMMING IN PYTHON EXAM STUDY
GUIDE 2026 TEST PAPER QUESTIONS AND
SOLUTIONS
◉ Read file. Answer: open("file.txt") || open("file.txt", "r") || with
open("file") as file:
◉ Write file. Answer: open("file.txt", "w")
◉ Append file. Answer: open("file.txt", "a")
◉ Multiple file actions. Answer: open("file.txt", "initialAction+")
◉ Set cursor (place in file) (to beginning). Answer: file.seek(0)
◉ Use CSV library. Answer: import csv
◉ Read csv file. Answer: with open("file.csv") as file: csv.reader(file)
◉ Read csv file as dictionary. Answer: with open("file.csv") as file:
csv.DictReader(file)