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 – 4
Multiple Choice Questions
61. file_object.readline( )
How much bytes reads by the above statement?
a) reads only one line at a time from the current cursor position
b) reads only 20 bytes from current cursor position.
c) Reads the entire file.
d) None of these
62. file_object.readline(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.
63. What types of value returns by read() function?
a) integer
b) list
c) string
d) None of these
64. What types of value returns by readline() function?
a) integer
b) list
c) string
d) None of these
65. What types of value returns by readlines() function?
a) integer
b) list
c) string
d) None of these
Direction ( Q66 – Q73 ) : Answer on the basis of given text file named ‘story.txt’ .
Hello dear students
I hope you are preparing well.
But, you need to do more practice.
All the best.
66. What is output of the given code ?
myfile = open("story.txt", "r")
str = myfile.read(10) # Line 1
print(str)
myfile.close()
a) Hello
b) Hello dear
c) Hello dear students
d) None of these
67. What is output of the given code ?
myfile = open("story.txt", "r")
str = myfile.readline() # Line 1
print(str)
myfile.close()
a) Hello
b) Hello dear
c) Hello dear students
d) None of these
68. What is output of the given code ?
myfile = open("story.txt", "r")
str = myfile.readline(6) # Line 1
str = myfile.readline() # Line 2
print(str)
myfile.close()
a) dear students
b) Hello dear
c) Hello dear students
d) None of these
69. What is output of the given code ?
myfile = open("story.txt", "r")
str = myfile.readlines()
print(str)
myfile.close()
a) Hello dear students
I hope you are preparing well.
But, you need to do more practice.
All the best.
b) Hello dear students I hope you are preparing well. But, you need to do more practice. All the best.
c) [‘Hello dear students\n’, ‘I hope you are preparing well.\n’, ‘But, you need to do more practice.\n’, ‘All the best.\n’]
d) None of these
70. What is output of the given code ?
myfile = open("story.txt", "r")
str = myfile.readline(6) # Line 1
str = myfile.readline() # Line 2
str = myfile.readline(6) # Line 3
print(str)
myfile.close()
a) Hello
b) I hope
c) I hope you are preparing well.
d) None of these
71. What is output of the given code ?
myfile = open("story.txt", "r")
str = myfile.read() # Line 1
print(len(str))
myfile.close()
a) 80
b) 21
c) 100
d) None of these
72. What is output of the given code ?
myfile = open("story.txt", "r")
str = myfile.readlines() # Line 1
print(len(str))
myfile.close()
a) 2
b) 4
c) 6
d) None of these
73. What is output of the given code ?
myfile = open("story.txt", "r")
str = myfile.readline() # Line 1
print(len(str.split()))
myfile.close()
a) 1
b) 2
c) 3
d) None of these
74. Which function can be used to write data into the text file?
a) write( )
b) writeline()
c) writelines()
d) Both (a) and (c)
75. Which function is use to write a ‘string’ into the text file?
a) write( )
b) writeline()
c) writelines()
d) Both (a) and (c)
76. Which function is use to write a ‘strings in list’ into the text file?
a) write( )
b) writeline()
c) writelines()
d) Both (a) and (c)
77. A file opened in _________ mode retains its previous data while allowing you to add newer data into.
a) write
b) read
c) append
d) Both (a) and (c)
78. A file opened in _________ mode overwrites an existing file or creates a non-existing file.
a) write
b) read
c) append
d) Both (a) and (c)
79. What types of value returns by write( ) method?
a) integer value
b) string value
c) list value
d) None of these
80. write( ) methods returns ______
a) string written in a file
b) number of characters written in file
c) size of file, in which it write
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