[go: up one dir, main page]

0% found this document useful (0 votes)
23 views2 pages

File Handling

The document contains a series of questions and multiple-choice answers related to file handling in programming, specifically focusing on how to open files for reading and writing, the concepts of pickling and unpickling, and the syntax of the open() function. It addresses the correct usage of file modes, functions for reading and writing characters, and the implications of file existence when opened in different modes. Each question provides options to test knowledge on these topics.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views2 pages

File Handling

The document contains a series of questions and multiple-choice answers related to file handling in programming, specifically focusing on how to open files for reading and writing, the concepts of pickling and unpickling, and the syntax of the open() function. It addresses the correct usage of file modes, functions for reading and writing characters, and the implications of file existence when opened in different modes. Each question provides options to test knowledge on these topics.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1. To open a file c:\scores.

txt for reading, we use _____________


a) infile = open(“c:\scores.txt”, “r”)
b) infile = open(“c:\\scores.txt”, “r”)
c) infile = open(file = “c:\scores.txt”, “r”)
d) infile = open(file = “c:\\scores.txt”, “r”)

2. To open a file c:\scores.txt for appending data, we use ____________


a) outfile = open(“c:\\scores.txt”, “a”)
b) outfile = open(“c:\\scores.txt”, “rw”)
c) outfile = open(file = “c:\scores.txt”, “w”)
d) outfile = open(file = “c:\\scores.txt”, “w”)

3. Which of the following statements are true?


a) When you open a file for reading, if the file does not exist, an error occurs
b) When you open a file for writing, if the file does not exist, a new file is created
c) When you open a file for writing, if the file exists, the existing file is overwritten with the
new file
d) All of the mentioned

4. Which of the following mode will refer to binary data?


a) r
b) w
c) +
d) b

5. What is the pickling?


a) It is used for object serialization
b) It is used for object deserialization
c) None of the mentioned
d) All of the mentioned

6. What is unpickling?
a) It is used for object serialization
b) It is used for object deserialization
c) None of the mentioned
d) All of the mentioned

7. What is the correct syntax of open() function?


a) file = open(file_name [, access_mode][, buffering])
b) file object = open(file_name [, access_mode][, buffering])
c) file object = open(file_name)
d) none of the mentioned

8. In file handling, what does this terms means “r, a”?


a) read, append
b) append, read
c) write, append
d) none of the mentioned
9. Which function is used to read all the characters?
a) Read()
b) Readcharacters()
c) Readall()
d) Readchar()

10. Which function is used to write all the characters?


a) write()
b) writecharacters()
c) writeall()
d) writechar()

You might also like