Question:

Which of the following methods is used to position a file object to a specific position in a file?

Show Hint

Remember:
- tell(): "Where am I?" (Returns current byte offset).
- seek(offset): "Go to this position" (Moves file pointer).
Updated On: Sep 7, 2026
  • tell()
  • peep()
  • move()
  • seek()
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

Concept:
When working with files in Python, the file pointer indicates the current byte offset where the next read or write operation will take place.
Python provides built-in methods on file objects to inspect and modify this byte offset.

Step 1: Understanding seek():

The seek(offset, whence) method reposition the file pointer to a specific byte location within the file.
- offset defines how many bytes to move.
- whence is an optional reference point: 0 (beginning of file, default), 1 (current position), or 2 (end of file).
Hence, seek() sets the file pointer to a chosen location.

Step 2: Evaluating tell() and Other Options:

- tell() returns the current integer byte offset of the file pointer without modifying it.
- Neither peep() nor move() are valid built-in file object methods in Python.
Final Answer:
The method used to position a file pointer to a designated location is seek().
Was this answer helpful?
0
0

Top CUET File Handling in Python Questions

View More Questions