Question:medium

Assertion (A): For a binary file opened using 'rb' mode,
the pickle.dump() method will display an error.
Reason (R): The pickle.dump() method is used to read from a binary file.

Show Hint

Use pickle.dump() to write,
and pickle.load() to read.
Always match the file mode accordingly.
Updated On: Jan 14, 2026
  • Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation for Assertion (A).
  • Both Assertion (A) and Reason (R) are true and Reason (R) is not the correct explanation for Assertion (A).
  • Assertion (A) is true but, Reason (R) is false.
  • Assertion (A) is false but, Reason (R) is true.
Show Solution

The Correct Option is C

Solution and Explanation

To serialize and write Python objects to a binary file, the pickle.dump() method is employed. This method requires the file to be opened in binary write mode, typically specified as 'wb'.

Attempting to use pickle.dump() on a file opened in binary read mode ('rb') will result in an error, as such files do not permit writing.

Consequently, Assertion (A) is accurate. Reason (R) is incorrect because pickle.dump() is for writing, not reading; the pickle.load() method is used for reading from binary files.

Therefore, option (C) is the correct selection.

Was this answer helpful?
0