File Handling in Python · Class 12 · CBSE · Science Computer Science

Explain the purpose of the seek() and tell() functions when working with a file in Python.

Practice question from File Handling in Python (Class 12 · CBSE · Science Computer Science), with the correct answer and a step-by-step solution.

hard · Subjective · Q-63D8E5

Explain the purpose of the seek() and tell() functions when working with a file in Python.

Answer: The tell() function returns the current position of the file pointer. The seek() function moves the file pointer to a specified position, usually measured from the beginning of the file when the default reference value is used. These functions allow a program to read or write data from a chosen location instead of only proceeding sequentially.

Solution

tell() reports the current file-pointer position, while seek() repositions the pointer. Together, they support random access to file contents.

More from File Handling in Python

All of File Handling in Python

Practise more Computer Science

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed