Test Index

CBSE Class 12 Computer Science 2025 Paper Set 4 Get it on Google PlayDownload on the App Store

© examsnet.com
Question : 20 of 37
Marks: +1, -0
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.
Solution:  
Concept:
pickle.dump(obj, file) writes (serialises) an object to a binary file; pickle.load(file) reads it back. The 'rb' mode opens a binary file for reading only.
Explanation:
Assertion: calling dump() on a file opened in 'rb' mode tries to write to a read-only file, so Python raises an error:
io.UnsupportedOperation: write
So (A) is true.
Reason: dump() is used to write, not read (reading is done by load()). So (R) is false.
Answer:
Option C (Assertion (A) is true but, Reason (R) is false.)
© examsnet.com
Advertisements
Go to Question: