Vidyalelo
Python · Q47

Files Handling in Python

Programming · Python · question 47

Q47

What will be the output of the following Python code? 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
Answer
D.
None of the mentioned

Answer: Option C

Solution

Answer: Option C
No explanation is given for this question Let's Discuss on Board