/en-tutor-prep-s5-ict-file-handling-exceptions-practice-1/
/en-tutor-prep-s5-ict-file-handling-exceptions-practice-1/
General Inquiry: info@TutorZone.com.hk
Office Hours: Monday to Saturday - 9:00 AM to 6:00 PM
WhatsApp Monday to Sunday - 24 hours
Hotline: +852 6828 1809
Instant Support: +852 9061 3106

Paper 1: File handling basics

Paper 1: File handling basics

  • 2026-11-21

Paper 1: File handling basics

Chapter practice with ten items, answers and a one-line note for each, about 25 minutes.

Paper 1 Ten items on this chapter with answers for immediate marking.

01 Paper details (check answers afterwards)

Item Detail
Questions 10
Suggested time 25
Difficulty mix Foundation 4 · Intermediate 2 · Challenge 2 · Error redo 2
Chapter Chapter: File handling and exceptions
Level Basic

02 Questions (10 items)

  1. FoundationOpening an existing file in ‘w’ mode, what happens to its content?
  2. FoundationWhere does data written in ‘a’ mode go?
  3. FoundationA file has 4 lines; how many elements does readlines() return?
  4. FoundationWhen is a file closed when opened with ‘with open(…) as f’?
  5. IntermediateWhich exception is raised when reading a file that does not exist?
  6. IntermediateIn Python, which exception does 10 divided by 0 raise?
  7. ChallengeHow many fields does “Class A,30,28,42” give after split(‘,’)?
  8. ChallengeA file has 3 lines with 4 fields each; how many fields in total?
  9. Error redoIn Python 3, what is 12 divided by 4, and what type is it?
  10. Error redoTo add a new record at the end of a file, use ‘w’ or ‘a’?

03 Answers and one-line notes

# Answer One-line note
1 It is cleared. ‘w’ truncates the file first, so old data is lost.
2 To the end of the file. ‘a’ appends, so new data always follows existing content.
3 4 elements. One element per line, each keeping its newline character.
4 When the with block ends. Even if an exception occurs inside, with still closes the file.
5 FileNotFoundError. Check the path first or catch that exception directly.
6 ZeroDivisionError. A zero divisor must be checked or caught.
7 4 fields. Comma-separated text files are usually split this way.
8 12 fields. 3 lines times 4 fields gives 12.
9 3.0, a float. Single-slash division always returns a float, even when exact.
10 ‘a’ mode. ‘w’ clears the whole file, while ‘a’ appends.

04 What to do after marking

  • After marking, redo only the wrong items and write down which step went wrong (formula, unit, or misread number).
  • Repeat the same item two days later; move to the next paper only when both attempts are correct.
  • Parents only need the answer and note columns; there is no need to explain every item.

Want the whole chapter? See all four difficulty papers on the chapter page.Tutor Registration →

Questions and answers are written originally by the TutorZone team and are not taken from any school, publisher or examination authority paper. Every value is checked by computer.

Join as a tutor or coach — academic, music, sports, arts, STEM. Free to register. See how it works →