Question:medium

Consider the following Python statement: 
F = open('CONTENT.TXT')
Which of the following is an invalid statement in Python? 
 

Show Hint

Always use valid whence} values (0, 1, or 2) with F.seek()} to avoid runtime errors.
Updated On: Jan 13, 2026
  • F.seek(1, 0)
     

  • F.seek(0, 1)
     

  • F.seek(0, -1)
     

  • F.seek(0, 2)
     

Show Solution

The Correct Option is C

Solution and Explanation

Python's seek() method modifies a file's current position. It accepts two arguments: 1. offset: the byte position to move the file pointer. 2. whence: the reference point for offset. The valid values for whence are: 0 for the beginning of the file, 1 for the current file position, and 2 for the end of the file. An offset value of -1 for whence is invalid, thus F.seek(0, -1) is an incorrect usage.

Was this answer helpful?
0

Top Questions on Commands and Requests