CBSE Class 12 Computer Science
Question 10 of 44
Solved 2025 Sample Question Paper CBSE Class 12 Computer Science (083) — Question 10
Back to all questionsfile.seek(0)
Reason — To move the file pointer to the beginning of the file, we can use the seek() method. When we pass 0 as the offset to this function, it moves the file pointer to the beginning of the file.
So the complete code is:
file = open("example.txt", "r")
data = file.read(100)
file.seek(0) # Move the file pointer to the beginning of the file
next_data = file.read(50)
file.close()