Text File
1.Which of the following mode cannot be used for opening the text file?
a)’r’ b)’w+’
c)’a’ d)’rb+’
2.What is the return datatype of read () function?
3.What is the return datatype of readlines() function?
4. Name the functions used to write data on the text files. Explain
5. What is the difference between ‘w’ and ‘a’ mode used while opening a text file?
6. Which of the following mode in file opening statement results or generates an error if the file does
not exist?
(a) a+ (b) r+ (c) w+ (d) None of the above
7. The correct syntax of seek() is:
(a) file_object.seek(offset [, reference_point])
(b) seek(offset [, reference_point])
(c) seek(offset, file_object)
(d) seek.file_object(offset)
8.Write the missing statement to complete the following code:
file = open("example.txt", "r")
data = file.read(100)
____________________ #Move the file pointer to the
beginning of the file
next_data = file.read(50)
file.close()
9.Write a python program to display the total number of words present in the file from a text file
“Quotes.Txt”.
10. Write a program to read the file letter.txt and display those words which has less than or equal to
four characters.