This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 32 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 32 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. What is the purpose of the mkdir() method? A) To rename a file. B) To create a directory. C) To delete a directory. D) To create a file. Show Answer Correct Answer: B) To create a directory. 2. What is the home directory? A) A folder for user files. B) A temporary storage location. C) A system folder. D) A type of file. Show Answer Correct Answer: A) A folder for user files. 3. How do you pass a default argument to a function? A) Call the function without any arguments. B) Define the function with default values, e.g., def my function(param1=default value):. C) Use a global variable instead of a parameter. D) Define the function without any parameters. Show Answer Correct Answer: B) Define the function with default values, e.g., def my function(param1=default value):. 4. Which constant is used to position the next I/O operation relative to the current position in fseek() function? A) SEEK END. B) SEEK SET. C) SEEK CUR. D) SEEK BEG. Show Answer Correct Answer: C) SEEK CUR. 5. What is the extension of a text file? A) .text. B) .ext. C) .txt. D) .tet. Show Answer Correct Answer: C) .txt. 6. Which mode is used to open a file for both reading and writing, creating the file if it doesn't exist, and truncating the file if it exists in Python? A) R+. B) W+. C) A+. D) X+. Show Answer Correct Answer: B) W+. 7. Which file mode will allow reading and writing without truncating existing data? A) 'r+'. B) 'w+'. C) 'a+'. D) Both a and c. Show Answer Correct Answer: A) 'r+'. 8. Explain the difference between text files and binary files. A) Text files contain only images and videos. B) Text files are always smaller than binary files. C) Binary files can be opened in any text editor. D) Text files are human-readable and consist of characters, while binary files are not human-readable and consist of bytes. Show Answer Correct Answer: D) Text files are human-readable and consist of characters, while binary files are not human-readable and consist of bytes. 9. What is the output of the following code?file = open('data.txt', 'r')print(file.read())file.close() A) The file 'data.txt' does not exist. B) The contents of the 'data.txt' file will be printed. C) An error will occur because the file is not opened in read mode. D) The code will print the file object instead of its contents. Show Answer Correct Answer: B) The contents of the 'data.txt' file will be printed. 10. Which of the following is not a mode for opening files? A) Replace. B) Append. C) Write. D) Read. Show Answer Correct Answer: A) Replace. 11. What is the purpose of the 'open' function in file handling? A) To close a file. B) To delete a file. C) To open a file. D) To rename a file. Show Answer Correct Answer: C) To open a file. 12. How can you write to a file in Python? A) Use the 'read' method to add content to the file. B) Write the content directly to the file without opening it. C) Open the file in read mode and directly modify its content. D) Open the file in write mode, use the 'write' method to add content, and close the file. Show Answer Correct Answer: D) Open the file in write mode, use the 'write' method to add content, and close the file. 13. What is the correct way to ensure a file is closed after operations are completed? A) Use the 'close()' method. B) Use the 'open()' method. C) Use the 'write()' method. D) Use the 'read()' method. Show Answer Correct Answer: A) Use the 'close()' method. 14. When a number is divided by 0, ..... is raised A) Name error. B) Import error. C) Index error. D) Zero division error. Show Answer Correct Answer: D) Zero division error. 15. Which module in Python is used for reading and writing binary files by converting Python objects into a byte stream and vice versa? A) Csv. B) Math. C) Pickle. D) Pandas. Show Answer Correct Answer: C) Pickle. 16. What is the expected output of the function add ..... two when called with parameters 2 and 1? A) 3. B) 1. C) Error. D) None. Show Answer Correct Answer: A) 3. 17. What is the difference between positional and keyword arguments? A) Positional arguments require the correct order, whereas keyword arguments allow for named parameters. B) Positional arguments can be used without any order. C) Keyword arguments are always mandatory in functions. D) Positional arguments are only used in class methods. Show Answer Correct Answer: A) Positional arguments require the correct order, whereas keyword arguments allow for named parameters. 18. When we open file in writing mode what will happen? A) All the previous data will be deleted. B) All the previous data will not be deleted. C) Both can be happen depending on the situation. D) None. Show Answer Correct Answer: A) All the previous data will be deleted. 19. ..... keyword is used to insert a module A) Import. B) Insert. C) Input. D) All These. Show Answer Correct Answer: A) Import. 20. How can you handle exceptions when opening a file in Python? A) Use a for loop to iterate through the file contents. B) Use a try-except block to catch exceptions when opening a file. C) Open the file without any error handling. D) Use a print statement to display the file contents. Show Answer Correct Answer: B) Use a try-except block to catch exceptions when opening a file. 21. Mode argument is mandatory. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: B) False. 22. What will be the output-f=open('abc.txt', 'a')text="xyz"f.write(text)f.close() A) Writing into the file without erasing old content. B) Writing into the file by erasing old content. C) Reading from the file without erasing old content. D) Reading from the file by erasing old content. Show Answer Correct Answer: A) Writing into the file without erasing old content. 23. What will be the output-f=open('abc.txt', 'w')print(f.name) A) Abc.txt. B) 'w'. C) Abc. D) File. Show Answer Correct Answer: A) Abc.txt. 24. We need not to close the file if we are opening file with 'with open( ..... ) as ..... block A) Yes. B) No. C) All the above. D) None of the above. Show Answer Correct Answer: A) Yes. 25. How do you create a cookie in PHP? A) Setcookie(). B) Createcookie. C) Makecookie(). D) None. Show Answer Correct Answer: A) Setcookie(). ← 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