Skip to main contentSkip to solution

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).

whenceReference point
0 (default)Beginning of file
1Current position
2End of file

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question