Question
Computer Science Question on File Handling in Python
Match List-I with List-II: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 |
A
(A) - (I), (B) - (II), (C) - (III), (D) - (IV)
B
(A) - (II), (B) - (I), (C) - (IV), (D) - (III)
C
(A) - (II), (B) - (I), (C) - (III), (D) - (IV)
D
(A) - (III), (B) - (IV), (C) - (I), (D) - (II)
Answer
(A) - (II), (B) - (I), (C) - (IV), (D) - (III)
Explanation
Solution
Each file operation serves a different purpose: readline() reads one line, writelines() writes multiple strings, seek() moves the pointer, and flush() writes unsaved data.