Paper 4: Common mistakes corrected
Chapter practice with ten items, answers and a one-line note for each, about 25 minutes.
| 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 | Retry |
| # | Answer | One-line note |
|---|---|---|
| 1 | No. | ‘w’ truncates the file; use ‘a’ to keep old data. |
| 2 | No. | read() returns a string; convert with int() or float() before arithmetic. |
| 3 | No. | A bare except catches everything, hiding real programming errors. |
| 4 | No. | Execution continues after the except block; that is the point of handling. |
| 5 | No. | finally always runs, successful or not, which suits releasing resources. |
| 6 | No. | Open handles are held and buffered data may never reach the disk. |
| 7 | No. | IndexError is an out-of-range sequence index; KeyError is a missing dictionary key. |
| 8 | No. | ‘a’ appends at the end and leaves old content unchanged. |
| 9 | No. | int() rejects decimal strings; use float(‘12.5’) first or a ValueError follows. |
| 10 | No. | A line loop holds one line at a time, while readlines() loads the whole file. |
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.

