Which method out of the following will allow the read operation from a Binary…

2023

Which method out of the following will allow the read operation from a Binary file in a Python program?

Answer: D. loadConceptIn the NCERT / CBSE Class 12 Computer Science course, binary files are handled with the pickle module. Serialisation is done with pickle.dump() to…

  1. A.

    read

  2. B.

    input

  3. C.

    accept

  4. D.

    load

Attempted by 1047 students.

Show answer & explanation

Correct answer: D

Concept

In the NCERT / CBSE Class 12 Computer Science course, binary files are handled with the pickle module. Serialisation is done with pickle.dump() to write an object to a binary file, and pickle.load() to read (de-serialise) an object back. In this curriculum the data is not 'read' but loaded, and not 'written' but dumped.

Application

To read from a binary file, the file is opened in binary-read mode and the object is retrieved with the load() method of the pickle module:

  1. Import the module: import pickle.

  2. Open the file in binary-read mode: f = open('data.dat', 'rb').

  3. Read the stored object: obj = pickle.load(f) — this returns the original Python object.

Cross-check / Contrast

  • input takes a line typed at the keyboard (standard input) and returns a string — it never touches a file.

  • accept is not a Python file-handling method at all; no such built-in exists for files.

  • read is the generic byte-stream method on a file object; while a file opened in 'rb' technically supports it, the NCERT binary-file convention pairs reading specifically with load(), which mirrors dump().

Explore the full course: Bpsc

Loading lesson…