Question:medium

Match List-I with List-II:
List-IList-II
(A) f.seek(-10,1)(I) From beginning of file, move 10 bytes forward
(B) f.seek(10,1)(II) From current position, move 10 bytes backward
(C) f.seek(10)(III) From current position, move 10 bytes forward
(D) f.seek(-10,2)(IV) From end of the file, move 10 bytes backward

Updated On: May 15, 2026
  • (A) - (I), (B) - (II), (C) - (III), (D) - (IV)
  • (A) - (II), (B) - (III), (C) - (IV), (D) - (I)
  • (A) - (III), (B) - (II), (C) - (IV), (D) - (I)
  • (A) - (II), (B) - (III), (C) - (I), (D) - (IV)
Show Solution

The Correct Option is D

Solution and Explanation

Solution: The objective is to associate file seeking function calls with their descriptions. In Python, the seek() method, applied to a file object, modifies the file's current position. Its signature is f.seek(offset, whence), where offset specifies the byte displacement and whence indicates the reference point.

  • whence=0: Repositions the pointer from the start of the file. This is the default behavior. (Example: f.seek(10))
  • whence=1: Repositions the pointer relative to the current file position. (Examples: f.seek(10,1) or f.seek(-10,1))
  • whence=2: Repositions the pointer relative to the end of the file. (Example: f.seek(-10,2))

Match the following statements to their meanings:

(A) f.seek(-10,1)(II) Move 10 bytes backward from the current position
(B) f.seek(10,1)(III) Move 10 bytes forward from the current position
(C) f.seek(10)(I) Move 10 bytes forward from the beginning of the file
(D) f.seek(-10,2)(IV) Move 10 bytes backward from the end of the file

The correct matching is as follows: (A) - (II), (B) - (III), (C) - (I), (D) - (IV)

Was this answer helpful?
1


Questions Asked in CUET (UG) exam