1.

What is the use of seek() method in files?(a) sets the file’s current position at the offset(b) sets the file’s previous position at the offset(c) sets the file’s current position within the file(d) none of the mentioned

Answer» Correct choice is (a) sets the file’s current position at the offset

Easiest explanation - Sets the file’s current position at the offset. The method seek() sets the file’s current position at the offset.

Following is the syntax for seek() method:

fileObject.seek(offset[, whence])

Parameters

offset — This is the position of the read/write pointer within the file.

whence — This is optional and defaults to 0 which means absolute file positioning, other values are 1 which means seek relative to the current position and 2 means seek relative to the file’s end.


Discussion

No Comment Found