This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 1 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 1 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. The correct syntax of the len function for string x: A) X.len(). B) Len[x]. C) LEN[]. D) Len(x). Show Answer Correct Answer: D) Len(x). 2. The correct syntax to close the file (name of file handle F) A) F(close). B) F.close(). C) F.close. D) Close(F). Show Answer Correct Answer: B) F.close(). 3. In order to work with a pickle mode you must first import A) Stdin(). B) Stdout(). C) Pickle. D) Stderr(). Show Answer Correct Answer: C) Pickle. 4. Delimeter for CSV file is A) Comma. B) Tab. C) Space. D) Semi-colon. Show Answer Correct Answer: A) Comma. 5. Choose the correct syntax of the replace function: A) X.Replace(x). B) X.replace(y). C) X.replace(3, x). D) X.replace("j", "3"). Show Answer Correct Answer: D) X.replace("j", "3"). 6. What does the 'r' mode do when opening a file? A) Opens a file for reading. B) Opens a file for writing. C) Creates a new file. D) Opens a file for appending. Show Answer Correct Answer: A) Opens a file for reading. 7. What is the purpose of the rewind() function? A) Reset file pointer to beginning. B) Close the file. C) Move pointer to end. D) Check for errors. Show Answer Correct Answer: A) Reset file pointer to beginning. 8. Inorder to avoid conflicts what concept is used in files A) Fblock(). B) Fclock(). C) Flock(). D) None. Show Answer Correct Answer: C) Flock(). 9. To create a csv file sales.csv, the correct syntax is ..... A) F=open('sales.csv', 'w'). B) F=open('sales.csv', 'r'). C) F=open('sales.csv', 'w+'). D) F=open('sales.csv', 'a'). Show Answer Correct Answer: A) F=open('sales.csv', 'w'). 10. How do you ensure that a file is properly closed after operations? A) Use a context manager or ensure to close the file in a finally block. B) Close the file only if an error occurs. C) Use a global variable to track the file state. D) Leave the file open until the program ends. Show Answer Correct Answer: A) Use a context manager or ensure to close the file in a finally block. 11. Which logical operator used to check for any one condition to be true? A) Or. B) And. C) Not. D) None. Show Answer Correct Answer: A) Or. 12. Fwrite() is used to write: A) Only integer. B) Only char. C) Structure data. D) File name. Show Answer Correct Answer: C) Structure data. 13. How do you write data to a binary file in Python? A) Use open('filename', 'rb') to read a binary file and file.read() to retrieve bytes. B) Write data to a text file using open('filename', 'w') and file.write(data) for strings. C) Use open('filename', 'wb') to open a binary file and file.dump(data) to write bytes. D) Use open('filename', 'wb+') to open a binary file and file.load(data) to add bytes. Show Answer Correct Answer: C) Use open('filename', 'wb') to open a binary file and file.dump(data) to write bytes. 14. Which of the following options is the correct Python statement to read and displaythe first 10 characters of a text file "poem.txt" ? A) F=open('poem.txt') print(F.load(10)). B) F=open('poem.txt') print(F.reader(10)). C) F=open('poem.txt', ) print(F.readline(10)). D) F=open('poem.txt') print(F.read(10)). Show Answer Correct Answer: D) F=open('poem.txt') print(F.read(10)). 15. Files being used by programs are copied into main memory A) TRUE. B) FALSE. C) All the above. D) None of the above. Show Answer Correct Answer: A) TRUE. 16. Which function is used to write all the charecters A) Write(). B) Writecharecters(). C) Writeall. D) Writechar(). Show Answer Correct Answer: A) Write(). 17. What is the use of "a" in file handling? A) Read. B) Write. C) Append. D) None of the mentioned. Show Answer Correct Answer: C) Append. 18. Which Python library is commonly used for GUI programming involving widgets like Label and Button? A) Tkinter. B) NumPy. C) Pandas. D) Matplotlib. Show Answer Correct Answer: A) Tkinter. 19. How do you read the entire content of a file in Python? A) Use 'with open("filename.txt", "r") as file:content = file.read()'. B) Employ 'with open("filename.txt") as file:content = file.readlines()'. C) Use 'open("filename.txt") as file:content = file.read()'. D) Read the file using 'file = open("filename.txt", "r") content = file.read()'. Show Answer Correct Answer: A) Use 'with open("filename.txt", "r") as file:content = file.read()'. 20. Why is it important to close a file in Python? A) To delete the file. B) To convert the file to binary format. C) To avoid syntax errors. D) To free up system resources. Show Answer Correct Answer: D) To free up system resources. 21. CSV stands for ..... A) Common separate variable. B) Comma Separates Values. C) Common Separated Values. D) Comma Separated Values. Show Answer Correct Answer: D) Comma Separated Values. 22. Which of the following is NOT a basic file handling operation? A) Open. B) Read. C) Write. D) Delete. Show Answer Correct Answer: D) Delete. 23. Which stream operator is used for reading data from a file? A) >>. B) >. C) <<. D) +=. E) . Show Answer Correct Answer: B) >. 24. The ..... function changes the position of the file pointer by placing the file pointer at the specified position in an open file A) Tell(). B) Loc. C) Seek(). D) Pos(). Show Answer Correct Answer: C) Seek(). 25. What is the difference between text and binary files? A) Text files are human-readable; binary files are not. B) Binary files can be opened in any text editor. C) Text files contain only images and videos. D) Text files are always larger than binary files. Show Answer Correct Answer: A) Text files are human-readable; binary files are not. Next →Related QuizzesClass 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 10Class 11 Computer Science Chapter 6 File Handling Quiz 11 🏠 Back to Homepage 📘 Download PDF Books 📕 Premium PDF Books