adplus-dvertising
frame-decoration

Question

What is the output of this program?
fo = open("foo.txt", "rw+")
print "Name of the file: ", fo.name
 
# Assuming file has following 5 lines
# This is 1st line
# This is 2nd line
# This is 3rd line
# This is 4th line
# This is 5th line
 
for index in range(5):
   line = fo.next()
   print "Line No %d - %s" % (index, line)
 
# Close opened file
fo.close()

a.

Compilation Error

b.

Syntax Error

c.

Displays Output

d.

None of the mentioned

Posted under Python

Answer: (c).Displays Output

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?