Which of the following methods is used to position a file object to a specific position in a file?
Which of the following methods is used to position a file object to a specific position in a file?
Solution
✅ Correct Option: 4
The seek() method moves the file pointer to a given position. Its syntax is f.seek(offset, whence), where offset is the number of bytes to move and whence is the reference point (0 = start of file, 1 = current position, 2 = end of file).
Option 1: tell() only returns the current position of the file pointer. It does not move it.
Options 2 and 3: peep() and move() are not file object methods in Python.
Related questions:
2025: 15 May Shift 2
2026: 21 May Shift 1