Question
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
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?
Similar Questions
Discover Related MCQs
Q. What is the use of seek() method in files?
View solution
Q. What is the use of truncate() method in file?
View solution
Q. Which is/are the basic I/O connections in file?
View solution
Q. Which of the following mode will refer to binary data?
View solution
Q. What is the pickling?
View solution
Q. What is unpickling?
View solution
Q. What is the correct syntax of open() function?
View solution
Q. Correct syntax of file.writelines() is?
View solution
Q. Correct syntax of file.readlines() is?
View solution
Q. In file handling, what does this terms means “r, a”?
View solution
Q. What is the use of “w” in file handling?
View solution
Q. What is the use of “a” in file handling?
View solution
Q. Which function is used to read all the characters?
View solution
Q. Which function is used to read single line from file?
View solution
Q. Which function is used to write all the characters?
View solution
Q. Which function is used to write a list of string in a file
View solution
Q. Which function is used to close a file in python?
View solution
Q. Is it possible to create a text file in python?
View solution
Q. Which of the following is modes of both writing and reading in binary format in file.?
View solution
Q. Which of the following is not a valid mode to open a file?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Python? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!