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()

7 Comments

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

Post a Comment

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

Previous Post Next Post