This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 47 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 47 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. Which method reads a single line from a file in Python? A) File.read(). B) File.readlines(). C) File.readline(). D) File.readchar(). Show Answer Correct Answer: C) File.readline(). 2. What is a file? A) A digital document that stores data. B) A temporary storage for data. C) A type of variable. D) A method in Python. Show Answer Correct Answer: A) A digital document that stores data. 3. What will this line of code do?myFile = open("test ..... scores.txt", "r") A) Opens the text file 'test scores' in reading mode. B) Opens the text file 'test scores' in writing mode-appends new data to the end of the file. C) Opens the text file 'test scores' in writing mode-overwrites contents. D) Opens the text file 'test scores' in wait mode. Show Answer Correct Answer: A) Opens the text file 'test scores' in reading mode. 4. In CSV files, what does each row represent? A) Each row represents a single record or data entry. B) Each row represents a header. C) Each row represents a paragraph. D) Each row represents a column. Show Answer Correct Answer: A) Each row represents a single record or data entry. 5. CSV file differs from binary file because: A) CSV is human-readable. B) CSV stores Python objects directly. C) CSV cannot be imported into Excel. D) CSV always takes less memory. Show Answer Correct Answer: A) CSV is human-readable. 6. When will the else part of try-except-else be executed? A) Always. B) When an exception occurs. C) When no exception occurs. D) When an exception occurs in to except block. Show Answer Correct Answer: C) When no exception occurs. 7. File formats are specified in the file extension A) TRUE. B) FALSE. C) All the above. D) None of the above. Show Answer Correct Answer: A) TRUE. 8. What exception does the createNewFile() method throw if an error occurs? A) FileAlreadyExistsException. B) NullPointerException. C) IOException. D) FileNotFoundException. Show Answer Correct Answer: C) IOException. 9. If you will have to store roll numbers of all the students, then which python datatype will you use? A) Set. B) Dictionary. C) List. D) Tuple. Show Answer Correct Answer: A) Set. 10. Which function is used to read records from a binary file? A) Pickle.load(f). B) Pickle.read(). C) Pickle.open(). D) Pickle.dump(l, f). Show Answer Correct Answer: A) Pickle.load(f). 11. What does the 'os.listdir()' function return? A) A list of all files in a directory. B) The size of a directory. C) The absolute path of a file. D) The current working directory. Show Answer Correct Answer: A) A list of all files in a directory. 12. What is advantage of binary files over text files? A) Easily human readable. B) Can directly store Python objects. C) Uses less disk space always. D) Cannot be corrupted. Show Answer Correct Answer: B) Can directly store Python objects. 13. What does the 'A' parameter do when opening a file? A) Opens the file in read-only mode. B) Clears the file before writing. C) Appends to the end of the file. D) Creates a new file. Show Answer Correct Answer: C) Appends to the end of the file. 14. Which command is used to open the file for read only A) Outfile = openReadWrite("temp.txt"). B) Outfile = openWrite("temp.txt"). C) Outfile = openRead("temp.txt"). D) None of them would do it. Show Answer Correct Answer: C) Outfile = openRead("temp.txt"). 15. Why is it important to close a file after performing file I/O operations? A) To prevent others from accessing the file. B) To free up resources tied with the file. C) To delete the file from the computer. D) To protect the file from viruses. Show Answer Correct Answer: B) To free up resources tied with the file. 16. There is only one way to read a file in python. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: B) False. 17. What does the following code do?f=open("test.txt") A) Opens the file in WRITE mode. B) Opens the file in READ mode. C) Opens the file both READING and WRITING. D) Syntax Error. E) None of the choices. Show Answer Correct Answer: B) Opens the file in READ mode. 18. What will the following code do?with open('file.txt', 'w') as f:f.write('Hello, world!') A) Create or open 'file.txt' and write 'Hello, world!' to it. B) Open 'file.txt' for reading and print 'Hello, world!'. C) Create 'file.txt' if it doesn't exist and write 'Hello, world!' to it. D) None of the above. Show Answer Correct Answer: A) Create or open 'file.txt' and write 'Hello, world!' to it. 19. What does the 'ungetc()' function in C do? A) Writes a character to a file. B) Reads a character from a file. C) Pushes a character back onto the input stream. D) Closes a file. Show Answer Correct Answer: C) Pushes a character back onto the input stream. 20. What does Filehandle.writelines (L) function do A) Writes all string in list L as lines to file refrence by filehandle. B) Reads all string in list L as lines to file refrence by file handle. C) Writes and reads. D) None. Show Answer Correct Answer: A) Writes all string in list L as lines to file refrence by filehandle. 21. In the data hierarchy, which of the choices contains multiple records? A) File. B) Records. C) Bits. D) Characters. Show Answer Correct Answer: A) File. 22. What does the 'eof' function check in file operations? A) Whether the file is writable. B) Whether the file is open. C) Whether the end of the file has been reached. D) Whether the file is empty. Show Answer Correct Answer: C) Whether the end of the file has been reached. 23. Which statement will return one line from a file (file object is 'f')? A) F.readline(). B) F.readlines(). C) F.read(). D) F.line. Show Answer Correct Answer: A) F.readline(). 24. 2 Which of the following statements are not true regarding the opening modes of a file? 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, an error occurs. C) When you open a file for writing, if the file does not exist, a new file is created. D) When you open a file for writing, if the file exists, the existing file is overwritten with the new file. Show Answer Correct Answer: B) When you open a file for writing, if the file does not exist, an error occurs. 25. The ..... device read from the keyboard. A) Stdout. B) Stdin. C) Stderr. D) None of this. Show Answer Correct Answer: B) Stdin. ← PreviousNext →Related QuizzesClass 11 Computer Science Chapter 6 File Handling Quiz 1Class 11 Computer Science Chapter 6 File Handling Quiz 2Class 11 Computer Science Chapter 6 File Handling Quiz 3Class 11 Computer Science Chapter 6 File Handling Quiz 4Class 11 Computer Science Chapter 6 File Handling Quiz 5Class 11 Computer Science Chapter 6 File Handling Quiz 6Class 11 Computer Science Chapter 6 File Handling Quiz 7Class 11 Computer Science Chapter 6 File Handling Quiz 8Class 11 Computer Science Chapter 6 File Handling Quiz 9Class 11 Computer Science Chapter 6 File Handling Quiz 10 🏠 Back to Homepage 📘 Download PDF Books 📕 Premium PDF Books