Computer Science
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.
Python File Handling
3 Likes
Answer
(a)
Both Assertion and Reason are true and Reason is the correct explanation of Assertion.
Explanation
Every open file maintains a file-pointer, which keeps track of the current position within the file. This file-pointer indicates the location in the file where the next read or write operation will occur. Every read and write operation takes place at the current position of the file pointer. When we perform a read operation, data is read from the file starting at the current position of the file pointer. Similarly, when we perform a write operation, data is written to the file starting at the current position of the file pointer. After each operation, the file pointer is automatically updated to reflect the new position in the file.
Answered By
1 Like
Related Questions
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. '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.
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.
What is the difference between "w" and "a" modes ?