This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 19 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 19 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. How do you handle a ValueError when converting input to an integer? A) Use a try-except block to catch ValueError during conversion. B) Ignore the error and proceed with the program. C) Convert the input to a string before conversion. D) Use a for loop to iterate through the input. Show Answer Correct Answer: A) Use a try-except block to catch ValueError during conversion. 2. Which mode do you use to open a file for reading in Python? A) W. B) A. C) R. D) Wb. Show Answer Correct Answer: C) R. 3. What is the purpose of the 'open()' function in programming? A) To close a file. B) To delete a file. C) To read from or write to a file. D) To rename a file. Show Answer Correct Answer: C) To read from or write to a file. 4. Readlines() method return? A) String. B) List. C) Dictionary. D) None of the above. Show Answer Correct Answer: B) List. 5. Which of the following functions is used to write data in the binary file? A) Load(). B) Dump(). C) Read(). D) Write(). Show Answer Correct Answer: B) Dump(). 6. Which mode in fopen() allows both reading and writing to a file without truncating it? A) "r". B) "w". C) "a". D) "r+". Show Answer Correct Answer: D) "r+". 7. What does the readlines() method return when reading a text file? A) A single string. B) A list of strings, each representing a line. C) A tuple of lines. D) A dictionary of lines. Show Answer Correct Answer: B) A list of strings, each representing a line. 8. Abhishek and Taran are working on a project that requires them to save data in a CSV file. They need to write a header row to the CSV file in Python without using DictWriter. How can they achieve this? A) Use the header argument in csv.writer() while writing rows. B) Write the header manually without using any library. C) Use open() and write() methods to create the header line. D) Use csv.writer() and call writerow() with the list of headers. Show Answer Correct Answer: D) Use csv.writer() and call writerow() with the list of headers. 9. Which header file is required for using file handling functions in C? A) String.h. B) Math.h. C) Stdlib.h. D) Stdio.h. Show Answer Correct Answer: D) Stdio.h. 10. What is the purpose of the Writer function in CSV file handling? A) The purpose of the Writer function is to write data to CSV files in Python. B) Writer function is used to convert CSV files into JSON format. C) Writer function is designed to create 3D models from CSV data. D) Writer function allows for real-time visualization of CSV data. Show Answer Correct Answer: A) The purpose of the Writer function is to write data to CSV files in Python. 11. What will happen if you try to open a file that does not exist in the read mode ("r") in Python? A) The file will be created. B) The file will be opened in write mode instead. C) An error will be raised. D) The file will be opened in append mode. Show Answer Correct Answer: C) An error will be raised. 12. Jika kita ingin menambahkan data ke file tanpa menghapus isi yang ada, kita menggunakan mode apa? A) Ios::trunc. B) Ios::out. C) Ios::in. D) Ios::app. Show Answer Correct Answer: D) Ios::app. 13. What is the extension of a binary file usually used in Python? A) .txt. B) .bin. C) .exe. D) .doc. Show Answer Correct Answer: B) .bin. 14. Difference between r+ and w+ A) No difference is there. B) In w+ mode the pointer is placed at begining and in r+ the pointer is placed at end. C) In r+ mode the pointer is placed at beginning and in w+ the pointer is placed at end. D) Both pointer of the modes are placed at start and end. Show Answer Correct Answer: B) In w+ mode the pointer is placed at begining and in r+ the pointer is placed at end. 15. Which mode in Python is used to open a file for creating (and return an error if the file exists)? A) R. B) X. C) All the above. D) None of the above. Show Answer Correct Answer: B) X. 16. Write the output of the following:f=open("test.txt", "w+") f.write("File-Handling") a=f.read(5) print(a) A) File-. B) File. C) File-H. D) No Output. Show Answer Correct Answer: D) No Output. 17. Read() function keep the file pointer at ..... A) BOF. B) EOF. C) EOL. D) EOP. Show Answer Correct Answer: B) EOF. 18. What is the function of 'os.makedirs()'? A) To list all directories. B) To delete a directory. C) To create multiple directories at once. D) To create a single directory. Show Answer Correct Answer: C) To create multiple directories at once. 19. Which of the following commands canbe used to read "n" number of characters from a file using the file object ? A) File.read(n). B) N = file.read(). C) File.readline(n). D) File.readlines(). Show Answer Correct Answer: A) File.read(n). 20. What does the relpath() function return? A) The absolute path of a file. B) The relative path between two locations. C) All the above. D) None of the above. Show Answer Correct Answer: B) The relative path between two locations. 21. What does the last byte of a file contain? A) Metadata. B) File pointer. C) End-of-file (EOF) character. D) Start of the file. Show Answer Correct Answer: C) End-of-file (EOF) character. 22. What is the purpose of error handling in file operations? A) To prevent crashes. B) To improve performance. C) To enhance user experience. D) To manage file types. Show Answer Correct Answer: A) To prevent crashes. 23. What is a file in the context of programming? A) A sequence of bytes on the disk. B) A temporary storage for data. C) A method to display data on the console. D) A type of variable in programming. Show Answer Correct Answer: A) A sequence of bytes on the disk. 24. In ..... storage value of variable is not lost even though the computer is not supplied electricity A) Non volatile. B) Volatile. C) A and b. D) None. Show Answer Correct Answer: A) Non volatile. 25. What will be the output of the following code?import java.io.*; class demoFile \{ public static void main(String args[]) \{File f = new File("C:/java/xyz"); System.out.print(f.getName()); \} \} A) Java. B) Xyz. C) Java/xyz. D) C:/java/xyz. Show Answer Correct Answer: B) Xyz. ← 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