Top 1000+ Solved Problem Solving and Python Programming MCQ Questions Answer
Q. fo.close()
a. compilation error
b. runtime error
c. no output
d. flushes the file when closing them
Q. Correct syntax of file.writelines() is?
a. file.writelines(sequence)
b. fileobject.writelines()
c. fileobject.writelines(sequence)
d. none of the mentioned
Q. Correct syntax of file.readlines() is?
a. fileobject.readlines( sizehint );
b. fileobject.readlines();
c. fileobject.readlines(sequence)
d. none of the mentioned
Q. In file handling, what does this terms means “r, a”?
a. read, append
b. append, read
c. write, append
d. none of the mentioned
Q. Which function is used to read all the characters?
a. read()
b. readcharacters()
c. readall()
d. readchar()
Q. Which function is used to read single line from file?
a. readline()
b. readlines()
c. readstatement()
d. readfullline()
Q. Which function is used to write all the characters?
a. write()
b. writecharacters()
c. writeall()
d. writechar()
Q. Which function is used to write a list of string in a file?
a. writeline()
b. writelines()
c. writestatement()
d. writefullline()
Q. Is it possible to create a text file in python?
a. yes
b. no
c. machine dependent
d. all of the mentioned
Q. 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+
Q. 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 the end for w+
c. in w+ the pointer is initially placed at the beginning of the file and the pointer is at the end for r+
d. depends on the operating system
Q. How do you get the name of a file from a file object (fp)?
a. fp.name
b. fp.file(name)
c. self. name (fp)
d. fp. name ()