Q. Write the output of the following code with justification if the contents of the file ABC.txt are:

Welcome to Python Programming!

f = open("ABC.txt", "r",)
size = len (f.read ())
print (size)
data = f.read(5)
print(data)


Output :-

30

>>> 

Explanation :-

size = len (f.read ()) give output 30 because ABC.txt contains 30 characters.

data = f.read(5) give no output because after size = len (f.read ()) statement the pointer go to last point of txt file.

 

4 Comments

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

  1. where is the answer
    or you cant do the question

    ReplyDelete
    Replies
    1. Sorry for inconvenience. I have uploaded answer.

      Delete
  2. Holy sit...where is answer if you can't solve it don't give us hole by only post the questions

    ReplyDelete
    Replies
    1. Sorry for inconvenience. I have uploaded answer.

      Delete

Post a Comment

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

Previous Post Next Post