To correctly order statements for Python file operations, follow this sequence: open the file, perform operations (e.g., writing), optionally provide feedback, and finally close the file. Detailed steps:
open() to create or open a file for writing. This initializes the file handler (f) for subsequent use.
write() method after opening to insert data into the file.
close() to securely terminate the file operation, freeing resources and ensuring data is saved.
Applying this order to the provided options yields:
Therefore, the correct sequence of statements is:
| List-I | List-II |
| (A) readline() | (I) Writes a sequence of strings to the file |
| (B) writelines() | (II) Reads a single line from the file |
| (C) seek() | (III) Force any buffered output to be written to the file |
| (D) flush() | (IV) Moves the file pointer to the specified position |