Computer Science
Assertion. 'Pickling' is the process whereby a Python object hierarchy is converted into a byte-stream.
Reason. Pickling process is used to work with binary files as a binary file works with byte-streams.
Python File Handling
1 Like
Answer
(b)
Both Assertion and Reason are true but Reason is not the correct explanation of Assertion.
Explanation
"Pickling" is the process whereby a Python object hierarchy is converted into a byte-stream. Pickling process is used to work with binary files as a binary file works with byte-streams. This is because binary files can efficiently store raw binary data, including the byte-streams produced by pickling. The use of binary files is just one of the many possible applications of pickling, but not the primary reason for its existence.
Answered By
1 Like
Related Questions
Assertion. The file modes "r", "w", "a" also reveal the type of file these are being used with.
Reason. The binary file modes have 'b' suffix with regular file modes.
Assertion. 'Pickling' is the process whereby a Python object hierarchy is converted into a byte-stream.
Reason. A binary file works with byte-streams.
Assertion. Every open file maintains a file-pointer and keeps track of its position after every operation.
Reason. Every read and write operation takes place at the current position of the file pointer.
Assertion. CSV (Comma Separated Values) is a file format for data storage which looks like a text file.
Reason. The information is organized with one record on each line and each field is separated by comma.