Q. What is the output of following code ?


fh = file ("poem.txt", "r")

size = len(fh.read())

print (fh.read (5))


Answer :-

No output

Explanation:- The fh.read() of line 2 will read the entire file content and place the file pointer at the end of file. For the fh.read (5), it will return nothing as there are no bytes to be read from EOF thus print() statement prints nothing.

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post