Check sibling questions

Write statements to place the file fp1:

(i) to beginning of file

(ii) to 25th byte from the beginning

(iii) to 10 bytes behind the current position of file pointer.

(iv) to 25 bytes behind the EOF position

 

Answer:

(i) to beginning of file : fp1.fseek(1)

(ii) to 25th byte from the beginning : fp1.(25,0)

(iii) to 10 bytes behind the current position of the file pointer : fp1.(-10,1)

(iv) to 25 bytes behind the EOF position : fp1.(-25,2)

  1. Computer Science - Class 12
  2. Chapter 2 - File Handling in Python

About the Author

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science and Computer Science at Teachoo