Identify the correct meaning of the code statement:
file.seek(10)
Identify the correct meaning of the code statement:
file.seek(10)
Solution
✅ Correct Option: 3
seek(offset, whence) takes whence as its second argument, and its default value is 0, which means the start of the file. So file.seek(10) is the same as file.seek(10, 0). It places the file pointer at byte position 10, counted from the beginning of the file.
Options 1 and 4: moving relative to the current position needs whence = 1, as in file.seek(10, 1). That is not the default.
Option 2: moving relative to the end needs whence = 2, as in file.seek(-10, 2).
| whence | Reference point |
|---|---|
| 0 (default) | Beginning of file |
| 1 | Current position |
| 2 | End of file |
Related questions:
2026: 19 May Shift 1
2025: 27 May Shift 2
2026: 29 May Shift 2