Important Python Mcqs

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

a) infile.read(2)

b) infile.read()

c) infile.readline()

d) infile.readlines()

Answer:

b) infile.read()

Explanation:

The read function is used to read all the lines in a file. read() will read in the entire file as a single string of text.
So option b is correct!

Related MCQs
Aniket Malik

Aniket Malik

CERTIFIED TUTOR/TRAINER WITH 300+ REVIEWS

Facing difficulty with

this concept?