File Handling Question Bank - True False Questions
File Handling Question Bank - True False Questions
Q11. When an existing file is opened in appending mode than KNOWLEDGE AND
file pointer is present at the end of the file. UNDERSTANDING
Q12. If a file is opened in r+, w+ or a+ mode, it can be used for KNOWLEDGE AND
both reading and writing. UNDERSTANDING
Q13. When we are writing strings using the write() method into KNOWLEDGE AND
a file one by one using iteration then a newline character UNDERSTANDING
is appended to each string by default so that all strings are
written in different lines in the file.
Q14 If a file is opened with “with open() as f” syntax then APPLICATION
after the control exiting the “with open()” block the file
get closed itself. (where f is file stream object)
Q15 A user wants to open a file ‘story.txt’ without losing the ANALYSIS,
content of the file and wants to continue writing after the EVALUATION AND
existing content. Also, if a file does not exist the file CREATION
should be created itself. He/she opened the file with
syntax :
f = open(“story.txt”, ‘r+”)
Is this statement true or false?
Q16. The file open using the with statement will close Understanding
automatically after with block is over.
Q17. The file mode “w” & “w+” are the same. Knowledge
Q18. When open a file into append mode , if the file does not Knowledge
exist , an error has been occurred.
Q19. The read( ) function reads the entire file at a time. Understanding
Q20 The readlines( ) function read the entire file in a list of Analysis
strings where each line is stored as one string.
Q21 Text file mode ‘a’ is in write only mode? KNOWLEDGE
(A)True (B) False
Q22. Text file mode ‘w+’ refer to write and read mode file? KNOWLEDGE
(A)True (B) False
Q23. A close() function breaks the link of file –object? KNOWLEDGE
(A)True (B) False
Q24. The following syntax is not correct- KNOWLEDGE
Myfile=open(r’E:\poem.txt’,”r”)
a) True b) False
a) True b) False
a) True b) False
Q30. dump( ) method is used to read data from a binary file Understanding
a) True b) False
Q31 read() method will read all the line of text file and return understanding
them in the form of list
(True/False)
Q32 Tell() method will identify the current location of file understanding
pointer in the file (True/False)
Q33 Open() method in read mode will create the file understanding
(True/False)
Q34 Readlines() method will returns the text file contents in understanding
the from of list of lines
(True/False)
Q35 Readline() method will returns the text file contents in the understanding
from of list of lines
(True/False)
Q36 f.seek (10,0) will move 10 bytes forward from beginning of file. Application
(A) True
(B) False
Q37 readlines( ) function returns all the words of the file in the Understanding
form of List. (T/F)
(A) True
(B) False
Q38 seek() function returns the current position of the file pointer Knowledge
(A) True
(B) False
Q39 readchar() function reads the all characters from the file Knowedge
(A) True
(B) False
Q50 The Binary files are used to store large data such as Analysis
images, video files, audio files etc.
Q51 Binary file stores information in ASCII or UNICODE Understanding
characters
A) TRUE
B) FALSE
Q52 The flush function forces the writing of data on the disk Understanding
still pending in output buffer.
A) TRUE
B) FALSE
Q53 Every line is a binary file is terminated with a EOL Knowledge
character.
A) TRUE
B) FALSE
Q54 The tell method tells the current position of the file Knowledge
pointer within the file
A) TRUE
B) FALSE
Q55 The dump method is used to read data from the binary file Knowledge
A) TRUE
B) FALSE
Q56 The pickle module can be used to directly store the Awareness about pickle
python module
objects onto the disk file.
Q57 pickle.loads( ) read the next line and store into disk file. Knowledge of basic
working of load( )
Q58 Deserialisation of records from file through pickle Awareness about basic
module should be guarded through try.. catch .. block. coding steps of using
pickle
Q59 A binary file 'employee.dat' contains 100 records, to add a Know about opening
new record into file, the file should be opened in 'wb' modes in case of binary
mode. file
Q60 Pickling is the process by which a Python object is Knowledge about saving
converted to a byte stream. process through pickle
module
Q61 A binary file can store data in the form of 0 and 1 Understanding
a) True
b) False
Q62 File object and file handle is the same thing Knowledge
a) True
b) False
Q63. Pickle.dump() function is use for writing data in binary Application
file.
a) True
b) False
Q64. pickle module contains read() and write() function. Knowledge
a) True
b) False
Q65. wb+ and w+b are same in respect of binary file. Knowledge
a) True
b) False
Q66. The load() function of the pickle module perform Evaluation
pickling.
a) TRUE
b) FALSE
Q67 File.seek(5,0) will move 5 bytes forward from the Analysis
beginning of the file.
a) TRUE
b) FALSE
Q68 There is a delimiter to end a line in Binary File. Knowledge
a) TRUE
b) FALSE
Q69 tell() method of Python tells us the current position Analysis
within the file.
a) TRUE
b) FALSE
Q70 When you open a file for writing, if the file exists, the Analysis
existing file is overwritten with the new file.
a) TRUE
b) FALSE
Q71 We cannot insert multiple rows in csv file using python Application
csv module
Q72 The default line terminator is \n in csv file Understanding
Q73 We can import csv module functions in following Creation
manner:
from csv import writerow, reader
Q74 A CSV file is a plain text file that can be opened in all kid Understanding
of programs
Q75 We have to insert header row in csv file using write() function Evaluation
as it is not included by default
Q76 A csv file is a binary file. Knowledge
(A) True
(B) False
Q77. The separator character of csv files is called delimiter. Knowledge
(A) True
(B) False
Q78 The csv files only take a comma as delimiter. Knowledge
(A) True
(B) False
Q79 You cannot insert multiple rows in a csv file using the csv Application
module.
(A) True
(B) False
Q80 You can import csv module functions for reading from Application
csv file and writing into csv file in the following manner:
from csv import writer, reader
(A) True
(B) False
ANSWER
Question No Answer
Q1 (B) False
Q2 (A) True
Q3. (A) True
Q4. (A) True
Q5. (A) True
Q6. True
Q7. True
Q8. False
Q9. True
Q10. False
Q11. True
Q12. True
Q13. False
Q14 True
Q15 False
Q16. True
Q17. False
Q18. False
Q19. True
Q20 True
Q21 True
Q22. True
Q23. True
Q24. False
Q25. False
Q26. True
Q27. True
Q28. True
Q29. False
Q30. False
Q31 False
Q32 True
Q33 False
Q34 True
Q35 False
Q36 A
Q37 A
Q38 B
Q39 B
Q40 B
Q41 False
Q42 False
Q43 False
Q44. True
Q45. True
Q46 True
Q47 True
Q48 False
Q49 False
Q50 True
Q51 FALSE
Q52 TRUE
Q53 FALSE
Q54 TRUE
Q55 FALSE
Q56 True
Q57 False
Q58 True
Q59 False
Q60 True
Q61 False
Q62 True
Q63. True
Q64. False
Q65. True
Q66. FALSE
Q67 TRUE
Q68 FALSE
Q69 TRUE
Q70 TRUE
Q71 False
Q72 True
Q73 True
Q74 False
Q75 True
Q76 b) False
Q77. a) True
Q78 b) False
Q79 b) False
Q80 a) True