CBSE-CS · Python Programming

File handling questions with answers

Build accuracy with explanation-led practice, then open a focused search or timed exam drill.

PRACTICE PREVIEW

Five questions to begin your revision

Open each answer only after choosing your own response.

01Medium · ✦ AI-labelled practice

A Class XII program must read an existing text file without changing it for record set 1. Which choice should it use?

  1. r
  2. w
  3. a
  4. rb
Check answer and explanation +
A — r

Mode r opens an existing text file for reading without changing its contents.

Source: CBSE Computer Science (083) curriculum 2026–27 · original syllabus-aligned practice
02Easy · ✦ AI-labelled practice

A Class XII program must replace the contents of a text file for record set 2. Which choice should it use?

  1. r
  2. a
  3. rb
  4. w
Check answer and explanation +
D — w

Mode w opens a text file for writing and truncates existing content.

Source: CBSE Computer Science (083) curriculum 2026–27 · original syllabus-aligned practice
03Easy · ✦ AI-labelled practice

A Class XII program must add text at the end of an existing file for record set 3. Which choice should it use?

  1. r
  2. wb
  3. a
  4. w
Check answer and explanation +
C — a

Mode a appends new text at the end while retaining the existing contents.

Source: CBSE Computer Science (083) curriculum 2026–27 · original syllabus-aligned practice
04Easy · ✦ AI-labelled practice

A Class XII program must read a binary file containing pickled records for record set 4. Which choice should it use?

  1. a
  2. rb
  3. r
  4. wb
Check answer and explanation +
B — rb

Binary data should be read using rb mode.

Source: CBSE Computer Science (083) curriculum 2026–27 · original syllabus-aligned practice
05Medium · ✦ AI-labelled practice

A Class XII program must write a new binary file containing pickled records for record set 5. Which choice should it use?

  1. wb
  2. w
  3. rb
  4. a
Check answer and explanation +
A — wb

Binary data should be written using wb mode.

Source: CBSE Computer Science (083) curriculum 2026–27 · original syllabus-aligned practice
✓

Know what you are practisingVerified and AI-generated records remain labelled separately. Previous-exam claims appear only when the source record supports them.

See every File handling question →