Q1. Which of the following commands is used to open a file “c:\temp.txt” in append-mode?
a. outfile - open(“c:/temp.txt”, “a”)
b. outfile - open(“c:\\temp.txt”, “rw”)
c. outfile - open(“c:\temp.txt”, “w+”)
d. outfile - open(“c:\\temp.txt”, “r+”)
Q2 What
are the binary files used for?
a. It is used to store data in the form
of bytes.
b. To store data
c. To look folder good
d. None of these
Q3. What
is the function of `rb` mode in binary?
a. Both reading and writing operations
can take place.
b. File is in only write mode.
c. File is created if it does not
exist.
d. File must exist otherwise error will
be shown.
Q4. What
is the description of `r+b` in binary mode?
a. read and write
b. write and read
c. read only
d. none of these
5. What
is binary file mode for append?
a. `rb`
b. `wb`
c. `ab`
d. None of these
Q6. What
is the binary file mode associated with “ file must exist, otherwise error will
be raised and reading and writing can take place”.
a. read and write
b. write and read
c. read only
d. append
Q7. What
is the process of converting a byte stream back to the original structure
called?
a. append
b. txt.file
c. Unpickling
d. None of these.
Q8. Which
module is used to store data into python objects with their structure?
a. pickle
b. binary files
c. unpickle
d. None of these
Q9. What
is pickle.dump()?
a. dump() function is used to store the
object data to the file.
b. It is used to read
c. append
d. None of these
Q10.
Which one of the following is the correct statement?
a. pickle import
b. import - pickle
c. import pickle
d. None of the above
Q11.
Which is the valid syntax to write an object onto a binary file opened in the
write mode?
a. pickle.dump(<object to be
written>, <file handle of open file>)
b. pickle.dump(<file handle of open
file>, <object to be written>)
c. dump.pickle(<object>, <file
handle>)
d. None of the above
Q12.
Which method is used for object serialization?
a. Pickling
b. Unpickling
c. None of the above
d. All of the above
Q13.
Which method of pickle module is used to read from a binary file?
a. dump()
b. load()
c. All of the above
d. None of the above
Q14.Which
method is used for object deserialization?
a. Pickling
b. Unpickling
c. All of the above
d. None of the above
Q15.Which
of the following is the correct syntax to read from a file using load function?
a. pickle.load(<filehandle>)
b. <object> -
load.pickle(<filehandle>)
c. <object> -
pickle.load(<filehandle>)
d. All of the above
Q16.
Which method of pickle module is used to write onto a binary file?
a. dump()
b. load()
c. All of the above
d. None of the above
Q17.
Which of the following file modes open a file for reading and writing both in
the binary file?
a. r
b. rb
c. rwb
d. rb+
Q18.Which
of the following file modes that opens a file for reading and writing both and overwrites
the existing file if the file exists otherwise creates a new file ?
a. w
b. wb+
c. rwb
d. rb
Q19.
Which of the following file modes opens a file for appending and reading in a
binary file and moves the files pointer at the end of the file if the file
already exists or creates a new file?
a. .a
b. .a+
c. .ab+
d. .ab
Q20.Which
of the following file modes will not delete the existing data in binary file?
a. .wb
b. .w
c. .a
d. .ab
ANSWER KEY
1-A |
6-A |
11-A |
16-A |
2-A |
7-C |
12-A |
17-D |
3-D |
8-A |
13-B |
18-B |
4-A |
9-A |
14-B |
19-C |
5-C |
10-C |
15-C |
20-D |
No comments:
Post a Comment