Q. Consider the file 'poemBTH.txt' given above (in previous question). What output will be produced by following code fragment?

obj1 = open('poemBTH.txt', 'r')

s1 = obj1.readline()

s2.readline(10)

s3 = obj1.read(15)

print(s3)

print(obj1.readline())

obj1.close()

 

Answer = It will print error that ‘s2’ is not defined.

If you want any output then write code given below in python and make poemBTH.txt in same directory :-

 

obj1 = open('Pathwalla.txt', 'r')
s1 = obj1.readline()
s2 = obj1.readline(10)
s3 = obj1.read(15)
print(s3)
print(obj1.readline())
obj1.close()

5 Comments

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

  1. If code is correct then
    what is the output?

    ReplyDelete
  2. If s2 is defined what is the output?

    ReplyDelete
    Replies
    1. I have given the bellow code copy it and run it .

      Delete

Post a Comment

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

Previous Post Next Post