Consider 'fileobj' as the file object. The method fileobj.seek(5, 0) will position the file object at:
Consider 'fileobj' as the file object. The method fileobj.seek(5, 0) will position the file object at:
Solution
✅ Correct Option: 2
The syntax is seek(offset, whence). Here the offset is 5 and whence is 0, which means "from the beginning of the file". So the file pointer moves to byte position 5 counted from the start.
Option 1: that would be seek(0, 0), where the offset is 0.
Option 3: that would be seek(0, 2), where whence 2 means the end of the file.
Option 4: that would need a negative offset from the end, such as seek(-5, 2).
Whence values: 0 is the start of the file, 1 is the current position, 2 is the end of the file.
Related questions:
2025: 22 May Shift 1
2026: 29 May Shift 2