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

When the file pointer has reached the end of a text file, what does readline() return?

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

easy · MCQ · Q-C8C3F1

When the file pointer has reached the end of a text file, what does readline() return?

  1. A.None
  2. B.An empty stringCorrect answer
  3. C.-1
  4. D.An empty list

Solution

readline() returns an empty string ('') when there is no more data to read because the end of the file has been reached.

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