1.
Which file content is human readable format ?
Correct Answer
B. Text File
Explanation
A text file is considered to be in human-readable format because it contains plain text that can be easily understood and interpreted by humans. Unlike a binary file, which contains data in a format that is not easily readable by humans, a text file can be opened and read using a simple text editor or word processor. The content of a text file is typically organized in lines and can include characters, numbers, symbols, and other readable text.
2.
When you open a file in a+ mode file pointer will be at
Correct Answer
B. End of File
Explanation
When you open a file in a+ mode, the file pointer will be at the end of the file. This means that any data written to the file will be appended to the existing content. If there is no existing content in the file, the file pointer will still be at the end of the file, ready for data to be written.
3.
In which mode all the files are opened in by default.
Correct Answer
A. Read mode
Explanation
By default, when files are opened, they are opened in read mode. This means that the file can only be read and its contents can be accessed, but no modifications can be made to the file. In read mode, the file pointer is positioned at the beginning of the file, allowing the user to read the file from the start.
4.
Name the module should be imported to operate with binary file .
Correct Answer
C. Pickle
Explanation
The correct answer is pickle. The pickle module in Python provides functions for serializing and deserializing objects. It is used to convert complex objects into a byte stream, which can be stored or transmitted, and then convert it back into the original object. This module is commonly used for working with binary files, as it allows for easy storage and retrieval of data in a compact format.
5.
Given the following code ….
File=open(“Mydata”,”a”)
File.close()
What type of file is mydata?
Correct Answer
B. Text File
Explanation
The file "Mydata" is a text file because it is opened with the mode "a" which stands for append. This mode is typically used for writing text to a file.
6.
Name the method used to know the current position of the file pointer
Correct Answer
B. Tell()
Explanation
The method used to know the current position of the file pointer is "tell()". This method returns the current position of the file pointer, which indicates the next byte that will be read or written. By using this method, we can keep track of the current position within a file and perform operations accordingly.
7.
Which module is required to use built in function dump()?
Correct Answer
C. Pickle
Explanation
The module required to use the built-in function dump() is pickle. The dump() function is used to serialize and save Python objects into a file. The pickle module provides the necessary functionality to perform this serialization process.
8.
Read the following code :
F1=open(“main.txt”,”w”)
F1.write(“BYE”)
print(F1.tell())
if the file contains “GOOD” before execution . What will be display after the execution of the above code:
Correct Answer
A. 7
Explanation
The code opens a file named "main.txt" in write mode and assigns it to the variable F1. It then writes the string "BYE" to the file. The print(F1.tell()) statement returns the current position of the file pointer, which is the number of characters written to the file so far. Since "BYE" has 3 characters, the file pointer is at position 3. Therefore, the answer is 7.
9.
The readlines() method return -----------------
Correct Answer
B. List of Lines
Explanation
The readlines() method in Python returns a list of lines from a file. Each line is represented as a string element in the list. Therefore, the correct answer is "List of Lines".
10.
From the following which file mode is used to read from a binary file.
Correct Answer
C. Rb
Explanation
The correct answer is "rb". In file modes, "r" is used to read from a file, but when dealing with binary files, the "b" is added to specify that the file is in binary format. This mode allows for reading binary data from the file.
11.
Current working directory / folder can be determined by using ------------------ method .
Correct Answer
B. Getcwd()
Explanation
The correct answer is "getcwd()". This method is used to determine the current working directory or folder.
12.
Opening a file in append mode erases the previous data
Correct Answer
B. False
Explanation
Opening a file in append mode does not erase the previous data. Instead, it allows new data to be added to the end of the file without overwriting or deleting the existing content. This is useful when we want to add new information to a file without losing the existing data.