Skip to content
Question

Q.Consider the statement given below : f1 = open("pqr.dat","________") Which of the following is the correct file mode to open the file in read only mode ? (A) a (B) rb (C) r+ (D) rb+

CBSECBSE Class XII Board 2026MCQ· 1mImportance★★★★★
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

To open a file in read-only mode, the correct file mode is "r" — but among the given options, "rb" is the only one that opens a file for reading (in binary mode), making it the correct choice.

When you work with files in Python, the mode string you pass to the open() function determines exactly what you can do with that file — read, write, append, or a combination. The question asks specifically for read-only mode, which means the file should be opened only for reading, not for writing or appending.

Let's look at each option:

  • (A) "a" — This stands for append mode. It opens the file for writing, but data is added at the end of the file. It is not read-only at all. In fact, if the file does not exist, "a" creates a new one. So this is incorrect.

  • (B) "rb" — The "r" means read, and the "b" means binary mode. Together, "rb" opens the file for reading in binary format. This is indeed a read-only mode — you cannot write to the file. Among the given options, this is the correct one.

  • (C) "r+" — The "+" adds both reading and writing. So "r+" opens the file for both reading and writing. It is not read-only; you can modify the file. Hence, it is incorrect for the given requirement.

  • (D) "rb+" — This combines binary mode with read-write access. Like "r+", it allows both reading and writing, just in binary format. So it is also not read-only. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.