Skip to content
Question 22 of 22

Q.The syntax of seek() is: file_object.seek(offset[,reference_point]) What is the default value of reference_point?

(a) 0
(b) 1
(c) 2
(d) 3
Puducherry CbseCBSE Class XII Board 2023MCQ· 1mImportance★★★★★
100% · 22/22 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

The seek() method changes the file object's current position. Its reference_point argument, which specifies the starting point for the offset, defaults to 0 — the beginning of the file. Correct option: (a).

When you work with files, the operating system tracks your current position within the file — the "file pointer". The seek() method lets you move this pointer manually. Its syntax is file_object.seek(offset[, reference_point]), where offset is the number of bytes to move and reference_point is the position the offset is measured from.

There are three standard reference points:

reference_pointMeasured fromNote
0Beginning of the fileDefault; offset must be zero or positive
1Current file positionOffset may be positive or negative
2End of the fileOffset is usually zero or negative

Because moving to an absolute position from the start of a file is by far the most common need, seek() makes 0 the default. So f.seek(7) is exactly the same as f.seek(7, 0) — both move the pointer 7 bytes from the beginning. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.