PYTHON MCQs
1.In file handling, what does this terms means “r, a”?
a) read, append
b) append, read
c) write, append
d) none of the mentioned
Answer: a) read, append
2. What is the use of “w” in file handling?
a) Read
b) Write
c) Append
d) None of the mentioned
Answer: b) Write
3. What is the use of “a” in file handling?
a) Read
b) Write
c) Append
d) None of the mentioned
Answer: c) Append
4. Which function is used to read all the characters?
a) Read()
b) Readcharacters()
c) Readall()
d) Readchar()
Answer: a) Read()
5. Which function is used to read single line from file?
a) Readline()
b) Readlines()
c) Readstatement()
d) Readfullline()
Answer: a) Readline()
6. Which function is used to write all the characters?
a) write()
b) writecharacters()
c) writeall()
d) writechar()
, PYTHON MCQs
Answer: a) write()
7. Which function is used to write a list of string in a file?
a) writeline()
b) writelines()
c) writestatement()
d) writefullline()
Answer: b) writelines()
8. Which function is used to close a file in python?
a) Close()
b) Stop()
c) End()
d) Closefile()
Answer: a) Close()
9. Is it possible to create a text file in python?
a) Yes
b) No
c) Machine dependent
d) All of the mentioned
Answer: a) Yes
10. Which of the following are the modes of both writing and reading in binary
format in file?
a) wb+
b) w
c) wb
d) w+
Answer: a) wb+
11.Which of the following is not a valid mode to open a file?
a) ab
b) rw
c) r+
d) w+
Answer: b) rw
12. What is the difference between r+ and w+ modes?
a) no difference
b) in r+ the pointer is initially placed at the beginning of the file and the pointer is at
1.In file handling, what does this terms means “r, a”?
a) read, append
b) append, read
c) write, append
d) none of the mentioned
Answer: a) read, append
2. What is the use of “w” in file handling?
a) Read
b) Write
c) Append
d) None of the mentioned
Answer: b) Write
3. What is the use of “a” in file handling?
a) Read
b) Write
c) Append
d) None of the mentioned
Answer: c) Append
4. Which function is used to read all the characters?
a) Read()
b) Readcharacters()
c) Readall()
d) Readchar()
Answer: a) Read()
5. Which function is used to read single line from file?
a) Readline()
b) Readlines()
c) Readstatement()
d) Readfullline()
Answer: a) Readline()
6. Which function is used to write all the characters?
a) write()
b) writecharacters()
c) writeall()
d) writechar()
, PYTHON MCQs
Answer: a) write()
7. Which function is used to write a list of string in a file?
a) writeline()
b) writelines()
c) writestatement()
d) writefullline()
Answer: b) writelines()
8. Which function is used to close a file in python?
a) Close()
b) Stop()
c) End()
d) Closefile()
Answer: a) Close()
9. Is it possible to create a text file in python?
a) Yes
b) No
c) Machine dependent
d) All of the mentioned
Answer: a) Yes
10. Which of the following are the modes of both writing and reading in binary
format in file?
a) wb+
b) w
c) wb
d) w+
Answer: a) wb+
11.Which of the following is not a valid mode to open a file?
a) ab
b) rw
c) r+
d) w+
Answer: b) rw
12. What is the difference between r+ and w+ modes?
a) no difference
b) in r+ the pointer is initially placed at the beginning of the file and the pointer is at