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

To read the entire remaining contents of the file as a string from a file object infile, we use ____________

 

Answer:

Checking the options:

  • (a) infile.read(2) - reads 2 characters.
  • (b) infile.read() - reads the entire remaining contents of the file as a string.
  • (c) infile.readline() - reads a line of input, and returns it in the form of a string. 
  • (d) infile.readlines() - It reads all lines and returns them in a list. 

So, the correct answer is (b).

Learn in your speed, with individual attention - Teachoo Maths 1-on-1 Class

Ask a doubt
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

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