This Quiz contains totally 10 Questions each carry 1 point for you.
1. Which of the following is used to open a file “c:demo.txt” in read-mode only?
infile = open(“c:demo.txt”, “r”)
infile = open(“c: demo.txt”, “r”)
infile = open(file = “c: demo.txt”, “r+”)
infile = open(file = “c: demo.txt”, “r+”)
Correct!
Wrong!
2. Which of the following is used to open a file “c:demo.txt” in write-mode only?
outfile = open(“c: demo.txt”, “w”)
outfile = open(“c: demo.txt”, “w”)
outfile = open(file = “c: demo.txt”, “w+”)
outfile = open(file = “c: demo.txt”, “w+”)
Correct!
Wrong!
3. Which of the following is used to open a file “c:demo.txt” in append-mode?
outfile = open(“c:/demo.txt”, “a”)
outfile = open(“c:demo.txt”, “rw”)
outfile = open(“c:demo.txt”, “w+”)
outfile = open(“c:demo.txt”, “r+”)
Correct!
Wrong!
4. To read the entire remaining contents of the file as a string from a file object infile, we use ____________
infile.read(2)
infile.readlines()
infile.readline()
infile.read()
Correct!
Wrong!
5. In order to read the next line of the file from a file object infile, we use
infile.read(2)
infile.read()
infile.readline()
infile.readlines()
Correct!
Wrong!
6. The readlines() method returns
str
a list of lines
a list of single characters
a list of integers
Correct!
Wrong!
7. Which one of the following is not attributes of file?
closed
softspace
rename
mode
Correct!
Wrong!
8. What is the use of seek() method in files?
sets the file’s current position at the offset
sets the file’s previous position at the offset
sets the file’s current position within the file
none of the mentioned
Correct!
Wrong!
9. Which is/are the basic I/O connections in file?
Standard Input
Standard Output
Standard Errors
All of the mentioned
Correct!
Wrong!
10. In file handling, what does this term means “r, a”?
read, append
append, read
write, append
none of the mentioned
Correct!
Wrong!
Share the quiz to show your results !
Subscribe to see your results
Ignore & go to results
Python-File-Handling-Quiz
You got %%score%% of %%total%% right
%%description%%
%%description%%
Loading...
