Python File Handling
- Class 12 Computer Science File Handling in Python MCQs Set 1
- Class 12 Computer Science File Handling in Python MCQs Set 2
- Class 12 Computer Science File Handling in Python MCQs Set 3
- Class 12 Computer Science File Handling in Python MCQs Set 4
- Class 12 Computer Science File Handling in Python MCQs Set 5
- Class 12 Computer Science File Handling in Python MCQs Set 6
- Class 12 Computer Science File Handling in Python MCQs Set 7
- Class 12 Computer Science File Handling in Python MCQs Set 8
- Class 12 Computer Science File Handling in Python MCQs Set 9
File Handling in Python MCQ’s Set – 3
Multiple Choice Questions
41. The default file-open mode is ___________.
a) read
b) write
c) append
d) None of these
42. Write a command to open a file named “mybio.txt” in write mode?
a) fileobject = open (“mybio.txt”, “w”)
b) fileobject = open(“mybio.txt”)
c) fileobject = open(“mybio.txt”, “r”)
d) None of these
43. Which of the following is not a valid Text file mode?
a) r
b) p
c) w
d) a
44. Which of the following is not a valid Text file mode?
a) r+
b) w+
c) wb+
d) a+
45. Which text file mode , open the file in write mode and allow to add new content in the file with the existing content of file?
a) r
b) p
c) w
d) a
46. Identify which one is the not true for ‘a+’ file mode?
a) File is created if does not exist.
b) If file exist, file’s existing data is retained; new data is appended.
c) if file exist, file is truncated.
d) Both reading and writing operations can take place.
47. Identify which one is the not true for ‘w+’ file mode?
a) File is created if does not exist.
b) If file exist, file’s existing data is retained; new data is appended.
c) if file exist, file is truncated.
d) Both reading and writing operations can take place.
48. Identify which one is the not true for ‘r’ file mode?
a) File is created if does not exist.
b) It is a default file mode.
c) File must exist already
d) Python raise an I/O error, if file does not exist.
49. An open file is closed by calling the ______ method of its file-object.
a) stop()
b) exit()
c) close( )
d) None of these
50. A _____ function breaks the link of file-object and the file on the disk.
a) open()
b) read()
c) close( )
d) write()
51. A _____ function create a link between a file-object and the file on the disk.
a) open()
b) read()
c) close( )
d) write()
52. Which file mode does not place the cursor (offset) at the beginning of the file?
a) r+ / r
b) w+ / w
c) a+ / a
d) None of these
53. Which file mode place the cursor (offset) at the beginning of the file?
a) r / r+
b) a
c) a+
d) None of these
54. Identify the valid statement for closing a file.
a) close(file_object)
b) file_object.close()
c) file_object.close(file_name)
d) None of these
55. Python provides mainly _______ types of read functions to read from a data file.
a) three
b) four
c) two
d) None of these
56. Which read function does not allow to read at most n bytes from a file?
a) readlines()
b) readline()
c) read()
d) None of these
57. Which read function does not returns the read bytes in the form of string?
a) read()
b) readline()
c) readlines()
d) None of these
58. Which read function returns the read bytes in the form of list?
a) read()
b) readline()
c) readlines()
d) None of these
59. file_object.read(20)
How much bytes reads by the above statement?
a) 20 bytes from current cursor position
b) 19 bytes from current cursor position
c) always reads first 20 bytes from the beginning of file.
d) always read first 19 bytes from the beginning of file.
60. file_object.read( )
How much bytes reads by the above statement?
a) By default reads only 10 bytes from current cursor position.
b) By default reads only 9 bytes from current cursor position.
c) Reads the entire file.
d) None of these
Python File Handling (MCQ’s)
- Class 12 Computer Science File Handling in Python MCQs Set 1
- Class 12 Computer Science File Handling in Python MCQs Set 2
- Class 12 Computer Science File Handling in Python MCQs Set 3
- Class 12 Computer Science File Handling in Python MCQs Set 4
- Class 12 Computer Science File Handling in Python MCQs Set 5
- Class 12 Computer Science File Handling in Python MCQs Set 6
- Class 12 Computer Science File Handling in Python MCQs Set 7
- Class 12 Computer Science File Handling in Python MCQs Set 8
- Class 12 Computer Science File Handling in Python MCQs Set 9
Python Revision Tour – Multiple Choice Questions (MCQ’s)
- Class 12 Computer Science MCQs Python Revision Tour Set – 1
- Class 12 Computer Science MCQs Python Revision Tour Set – 2
Python Functions – Working with Functions (MCQ’s)
- Class 12 Computer Science Python Functions – Working with Functions MCQs Set – 1
- Class 12 Computer Science Python Functions – Working with Functions MCQs Set – 2
- Class 12 Computer Science Python Functions – Working with Functions MCQs Set – 3
- Class 12 Computer Science Python Functions – Working with Functions MCQs Set – 4
- Class 12 Computer Science Python Functions – Working with Functions MCQs Set – 5
- Class 12 Computer Science Python Functions – Working with Functions MCQs Set – 6