This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 7 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 7 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. Which function is used to open a file for reading in Python? A) Load. B) Read. C) Start. D) Open. Show Answer Correct Answer: D) Open. 2. What does this code do?file.write ( "Jumanji" ) A) It deletes the name "Jumanji" to the file. B) It deletes the name "Juman" to the file. C) It writes the name "Jumanji" to the file. D) It writes the name "Juman" to the file. Show Answer Correct Answer: C) It writes the name "Jumanji" to the file. 3. Those values are called as Default values: A) Defined in function Header. B) Defined in function. C) Defined in main. D) Defined in above def() statement. Show Answer Correct Answer: A) Defined in function Header. 4. What does the "r" mode do when opening a file in Python? A) Reads and writes to a file. B) Reads a file, creates a new file if it does not exist. C) Reads a file, error if the file does not exist. D) Reads a file, truncates the file first. Show Answer Correct Answer: C) Reads a file, error if the file does not exist. 5. Which statement will read 5 characters from a file(file object 'f')? A) F.read(). B) F.read(5). C) F.reads(5). D) None of the above. Show Answer Correct Answer: B) F.read(5). 6. EOF stands for? A) End of File. B) End on File. C) All the above. D) None of the above. Show Answer Correct Answer: A) End of File. 7. How many parameters used to pass while opening a file? A) 2. B) 3. C) 1. D) 0. Show Answer Correct Answer: A) 2. 8. What is a 'file handle' in the context of opening a file? A) A tool to physically handle files. B) A special variable that points to the opened file. C) A password needed to access the file. D) The graphical icon of the file. Show Answer Correct Answer: B) A special variable that points to the opened file. 9. How do you write a list of strings to a file in Python? A) With open('filename.txt', 'w') as f:f.writelines(" .join(list of strings)). B) F.write(list of strings). C) Using print(list of strings). D) Open('filename.txt', 'r') as f:. Show Answer Correct Answer: A) With open('filename.txt', 'w') as f:f.writelines(" .join(list of strings)). 10. What happens to the cursor after 'readline()' is called? A) It moves to the beginning of the file. B) It moves to the end of the line just read. C) It remains at the current position. D) It moves to the beginning of the next line. Show Answer Correct Answer: D) It moves to the beginning of the next line. 11. How do you write to a file in append mode? A) Use open('filename.txt', 'a') to open a file in append mode. B) Use open('filename.txt', 'x') to open a file in exclusive creation mode. C) Use open('filename.txt', 'w') to open a file in write mode. D) Use open('filename.txt', 'r') to open a file in read mode. Show Answer Correct Answer: A) Use open('filename.txt', 'a') to open a file in append mode. 12. What does strip() function do? A) Removes the trailing or leading spaces, if any. B) Deletes the file. C) Remove the file object. D) Removes all the spaces between words. Show Answer Correct Answer: A) Removes the trailing or leading spaces, if any. 13. Given "myFile" is a file handle-what best describes what the following Python code does:for aLine in myFile:print(aLine) A) It writes the contents from the file handle myFile to the console. B) It reads each line from the file handle myFile, assigns it to a variable called aLine and prints to the console. C) It removes each line from the file handle myFile. D) It copies each line from the file handle myFile to a new file. Show Answer Correct Answer: B) It reads each line from the file handle myFile, assigns it to a variable called aLine and prints to the console. 14. What is a library in python? A) COLLECTION OF FILES. B) COLLECTION OF MODULES. C) IT IS SUBPROGRAM. D) NAME OF A FILE. Show Answer Correct Answer: B) COLLECTION OF MODULES. 15. What are the main differences between paging and segmentation? A) Paging is used for process management; segmentation is for file storage. B) Paging allows variable-sized pages; segmentation uses fixed-size segments. C) Paging uses fixed-size pages; segmentation uses variable-sized segments. D) Paging divides memory into segments; segmentation divides it into pages. Show Answer Correct Answer: C) Paging uses fixed-size pages; segmentation uses variable-sized segments. 16. What is data dependency? A) A type of data error. B) A method to write data. C) A requirement for data to be in a specific order. D) A Python library for file handling. Show Answer Correct Answer: C) A requirement for data to be in a specific order. 17. Which of the statement is not true regarding the opening mode 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 reading in r+ mode, if the file does not exist, an error occurs. D) When you open a file for reading in w+ mode, if the file does not exist, a new file is created. Show Answer Correct Answer: B) When you open a file for writing, if the file does not exist, an error occurs. 18. What role does a cursor play in file handling? A) It encrypts the data being written to a file. B) It manages the security of a file. C) It keeps track of the current location within the file when reading or writing. D) It compresses the file data for storage efficiency. Show Answer Correct Answer: C) It keeps track of the current location within the file when reading or writing. 19. What is pickling? A) Pickling is a technique for compressing data files. B) Pickling is the serialization of a Python object into a byte stream. C) None of the mentioned. D) All of the mentioned. Show Answer Correct Answer: B) Pickling is the serialization of a Python object into a byte stream. 20. If a text file pointer is at the end after reading, which function resets it to the beginning? A) F.restart(). B) F.flush(). C) F.seek(0). D) F.reset(). Show Answer Correct Answer: C) F.seek(0). 21. What is the main focus of the practical implementation section? A) Writing programs. B) Reading files. C) Error handling. D) CSV files. Show Answer Correct Answer: A) Writing programs. 22. Overwrites existing data, starting from the beginning of the file. File is created if it doesn't already exist. A) Read. B) Append. C) Write. D) None of the above. Show Answer Correct Answer: C) Write. 23. Which of the statements is used to import all names from a module into the current calling module A) Import. B) From. C) Dir(). D) Import*. Show Answer Correct Answer: D) Import*. 24. Which of the following keyword not only belong to exception handling (It's under common keyword) A) Try. B) Except. C) Else. D) Finally. Show Answer Correct Answer: C) Else. 25. Apa yang dilakukan perror dalam program C? A) Menulis data ke file. B) Menampilkan pesan kesalahan. C) Membuka file. D) Menutup file. Show Answer Correct Answer: B) Menampilkan pesan kesalahan. ← 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 8Class 11 Computer Science Chapter 6 File Handling Quiz 9Class 11 Computer Science Chapter 6 File Handling Quiz 10Class 11 Computer Science Chapter 6 File Handling Quiz 11 🏠 Back to Homepage 📘 Download PDF Books 📕 Premium PDF Books