(1) fp.seek(r): This is incorrect because it only specifies the relative position 'r' but not the offset 'n'. 'seek' requires both an offset and a position to move the file pointer.
(2) fp.seek(n): This is also incorrect. While it specifies the offset 'n', it does not specify the reference position from which to seek. The 'seek' function needs a reference point.
(3) fp.seek(n, r): This is the correct syntax. It takes the file pointer to the 'n'th character with respect to the 'r' position. 'n' is the offset, and 'r' is the reference position (0: beginning, 1: current, 2: end).
(4) seek(n,r).fp: This is incorrect because the file pointer should come first when calling the function.
Therefore, the correct method is (3) fp.seek(n, r).
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 |
List I | List II | ||
A. | tell() | I. | This function used to position the file object at particular position in a file |
B. | seek() | II. | This function returns an integer that specifies the current position of the object in the file |
C. | dump() | III. | This function is used to convert Python objects for writing data in a binary file |
D. | load() | IV. | This function is used to load data from a binary file |
List-I (Words) | List-II (Definitions) |
(A) Theocracy | (I) One who keeps drugs for sale and puts up prescriptions |
(B) Megalomania | (II) One who collects and studies objects or artistic works from the distant past |
(C) Apothecary | (III) A government by divine guidance or religious leaders |
(D) Antiquarian | (IV) A morbid delusion of one’s power, importance or godliness |