This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 65 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 65 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. When writing to a file you cannot create new lines. A) False. B) True. C) All the above. D) None of the above. Show Answer Correct Answer: A) False. 2. Assertion:The file modes "r" , "w" , "a" also reveal the type of file these are being used with. Reason:The binary file modes have 'b' suffix with regular file modes. A) Both A and R are true and R is the correct explanation of A. B) Both A and R are true and R is not the correct explanation of A. C) A is true but R is false (or partly true). D) A is false (or partly true) but R is true. Show Answer Correct Answer: A) Both A and R are true and R is the correct explanation of A. 3. Which data type would you use for the quantity of stock in a shop? A) Integer. B) Float. C) String. D) Boolean. Show Answer Correct Answer: A) Integer. 4. Which method is used to retrieve or read pickled data from a binary file into a Python object? A) Read(). B) Open(). C) Dump(). D) Load(). Show Answer Correct Answer: D) Load(). 5. Which of the following statements about file paths is true? A) File paths are not case-sensitive on Windows and macOS. B) File paths must always be absolute. C) File paths are case-sensitive on all operating systems. D) File paths can only use backslashes. Show Answer Correct Answer: A) File paths are not case-sensitive on Windows and macOS. 6. Which statement is used for error handling in file operations? A) If-else. B) Try-except. C) Validate(). D) Handle(). Show Answer Correct Answer: B) Try-except. 7. Which one uses the open() function under read mode correctly and saves the file object to a variable? A) Open("myFile.txt", "r"). B) File = open("myFile.txt", "a"). C) File = open("myFile.txt", r). D) File = open("myFile.txt", "r"). Show Answer Correct Answer: D) File = open("myFile.txt", "r"). 8. Which of the following is a type of file in Python? A) All of the above. B) Binary file. C) Text file. D) Executable file. Show Answer Correct Answer: A) All of the above. 9. What is the method to write data to a file in Python? A) Write data directly to the console instead. B) Use the 'open' function with 'w' or 'a' mode and the 'write' method. C) Use the 'read' function to access file data. D) Use the 'append' function without opening a file. Show Answer Correct Answer: B) Use the 'open' function with 'w' or 'a' mode and the 'write' method. 10. Let x= "Python", the output of print(x.upper()) is A) Python. B) PYTHON. C) PYTHON. D) "PYTHON". Show Answer Correct Answer: B) PYTHON. 11. What does the abspath() function do? A) Converts a relative path to an absolute path. B) Checks if a path is absolute. C) All the above. D) None of the above. Show Answer Correct Answer: A) Converts a relative path to an absolute path. 12. What will be the output of the following code snippet?f = open("abc.txt", "w")x = f.read()f.close()print (x) A) Error (Not readable). B) Error (Not writable). C) It will read all the data of the file. D) None of the above. Show Answer Correct Answer: A) Error (Not readable). 13. Which of the following is not a method of opening files? A) Replace. B) Append. C) Write. D) Read. Show Answer Correct Answer: A) Replace. 14. What is the purpose of the flush() method in Python file handling? A) To delete the file contents. B) To rename the file. C) To clear the internal buffer and write data to the file immediately. D) To increase the file size. Show Answer Correct Answer: C) To clear the internal buffer and write data to the file immediately. 15. What are the two parameters of the open() function in Python? A) File and type. B) Path and class. C) Filename and mode. D) Directory and access. Show Answer Correct Answer: C) Filename and mode. 16. Which of the following statements is true about text files? A) They are always larger than binary files. B) They can only contain numbers. C) They require special software to read. D) They can be opened in a text editor. Show Answer Correct Answer: D) They can be opened in a text editor. 17. What is the correct way to add 1 to the $ count variable? A) $ count++;. B) Count++;. C) $ count =+1. D) ++count. Show Answer Correct Answer: A) $ count++;. 18. Which mode is used to open the text file for reading purpose? A) 'w'. B) 'r'. C) 'a'. D) 'rb'. Show Answer Correct Answer: B) 'r'. 19. Which type of file represent in tabular form / Record A) Binary. B) Text. C) CSV. D) All of the above. Show Answer Correct Answer: C) CSV. 20. What is the difference between writing to a file and appending to a file in Python? A) Writing to a file and appending to a file both delete the existing content. B) The difference is that writing to a file overwrites the existing content, while appending to a file adds new data at the end. C) Writing to a file and appending to a file are the same thing. D) Writing to a file adds new data at the end, while appending overwrites the existing content. Show Answer Correct Answer: B) The difference is that writing to a file overwrites the existing content, while appending to a file adds new data at the end. 21. What is the return type of fread() function in C? A) Float. B) Char. C) Size t. D) Int. Show Answer Correct Answer: C) Size t. 22. Which of the following is used to open a file in write mode? A) Wt. B) Write. C) S. D) W. Show Answer Correct Answer: D) W. 23. How many parameters does the open() function take in Python? A) One. B) Two. C) Three. D) Four. Show Answer Correct Answer: B) Two. 24. What is the syntax to read a file in Python? A) Open(file path).read(). B) File.read(). C) Open(file path).write(). D) Open(file path).readlines(). Show Answer Correct Answer: A) Open(file path).read(). 25. Which library is commonly used for Machine Learning programs in Python? A) Math. B) Sci-mod. C) Mach-learn. D) Scikit-learn. Show Answer Correct Answer: D) Scikit-learn. ← 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