This quiz works best with JavaScript enabled. Home > Class 11 > Class 11 Computer Science Chapter 6 File Handling – Quiz 55 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 11 Computer Science Chapter 6 File Handling Quiz 55 (25 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. Which function is used to read a character from a file? A) Fgetc(). B) Getchar(). C) Getcfile(). D) Filechar(). Show Answer Correct Answer: A) Fgetc(). 2. The ..... function removes the given character from both ends. A) Strip(). B) Lstrip(). C) Rstrip(). D) All these. Show Answer Correct Answer: A) Strip(). 3. What will be the output of the following Python code?lst = [1, 2, 3]lst[3] A) NameError. B) ValueError. C) IndexError. D) TypeError. Show Answer Correct Answer: C) IndexError. 4. Suresh wants to open the binary file student.dat in read mode. Which of the following modes should he use? A) R. B) Rb. C) W. D) Wb. Show Answer Correct Answer: B) Rb. 5. In Seek () ..... is a number specifying number of bytes. A) Offset. B) Mode. C) File object. D) Nine of this. Show Answer Correct Answer: A) Offset. 6. What is the purpose of fclose()? A) Opens a file. B) Closes an open file. C) Reads formatted input from a file. D) Checks for end of file. Show Answer Correct Answer: B) Closes an open file. 7. The ..... text file a specific character is stored to separate values A) Regular text file. B) Delimited text file. C) CSV File. D) Binary File. Show Answer Correct Answer: B) Delimited text file. 8. This command will open MyFile = open('MyText.txt', 'r') A) To write to the file. B) To read the file. C) To append to the file. D) None of the above. Show Answer Correct Answer: B) To read the file. 9. Which symbol is used for append mode? A) Ap. B) A. C) W. D) None of the above. Show Answer Correct Answer: B) A. 10. Which of the following is NOT a valid file access mode in Python? A) R. B) Z. C) W. D) A. Show Answer Correct Answer: B) Z. 11. What is the significance of the 'with' statement when handling files in Python? A) The 'with' statement is used to create new files in Python. B) The 'with' statement simplifies file handling by ensuring proper resource management. C) The 'with' statement allows for multiple files to be opened simultaneously without any issues. D) The 'with' statement is only necessary for reading files, not writing them. Show Answer Correct Answer: B) The 'with' statement simplifies file handling by ensuring proper resource management. 12. Which mode in file handling will create a file, if the file does not exist? A) R. B) W. C) A. D) NONE. Show Answer Correct Answer: B) W. 13. The command used to skip a row in a CSV file is A) Next(). B) Skip(). C) Omit(). D) Bounce(). Show Answer Correct Answer: A) Next(). 14. Which method is used to read a single line from a file in Python? A) Readline(). B) Writelines(). C) Seek(). D) Open(). Show Answer Correct Answer: A) Readline(). 15. Which function is used to determine if a directory exists or not? A) Os.path.find(). B) Os.path.exists(). C) Os.path.isdir(). D) Os.path.isfile(). Show Answer Correct Answer: C) Os.path.isdir(). 16. What is the significance of using serialization in Java? A) It allows objects to be converted into a string for storage. B) It helps in sorting arrays in Java. C) It is used for creating random numbers in Java. D) It allows objects to be converted into a byte stream for storage or transmission. Show Answer Correct Answer: D) It allows objects to be converted into a byte stream for storage or transmission. 17. Which of the following function is used to write or store data (objects) to a binary file? A) Write(). B) Output(). C) Dump(). D) Send(). Show Answer Correct Answer: C) Dump(). 18. How do you read a file line by line in a loop? A) With file('filename.txt') as f:. B) With open('filename.txt', 'r') as file:for line in file:print(line.strip()). C) For line in read(file):. D) Open('filename.txt') as file:. Show Answer Correct Answer: B) With open('filename.txt', 'r') as file:for line in file:print(line.strip()). 19. How can you check if a file exists before opening it? A) Use 'file.exists(file path)' to verify file presence. B) Employ 'os.path.isfile(file path)' to confirm file status. C) Use 'os.path.exists(file path)' to check if a file exists. D) Check 'os.file exists(file path)' for file existence. Show Answer Correct Answer: C) Use 'os.path.exists(file path)' to check if a file exists. 20. Which of the following function is used to write data in binary mode? A) Write. B) Output. C) Dump. D) Send. Show Answer Correct Answer: C) Dump. 21. How do you handle errors while working with files in Python? A) Ignore the errors and continue with the execution of the program. B) Use if-else statements to handle errors while working with files in Python. C) Use break statements to handle errors while working with files in Python. D) Use try-except blocks to handle errors while working with files in Python. Show Answer Correct Answer: D) Use try-except blocks to handle errors while working with files in Python. 22. Which method is used to write a list of strings to a file? A) 'write()'. B) 'writelines()'. C) 'readlines()'. D) 'read()'. Show Answer Correct Answer: B) 'writelines()'. 23. Can opening a file in 'write' or 'append' mode create a new file? A) Neither 'write' nor 'append' mode can create a new file. B) In both 'write' and 'append' modes. C) Only in 'append' mode. D) Only in 'write' mode. Show Answer Correct Answer: B) In both 'write' and 'append' modes. 24. Which function is used to save a file A) Save(). B) Stop(). C) Close(). D) End(). Show Answer Correct Answer: C) Close(). 25. Which of the following is the correct syntax of file object 'fobj' to write sequence data type using writelines() function? A) File.writelines(sequence). B) Fobj.writelines(). C) Fobj.writelines(sequence). D) Fobj.writeline(). Show Answer Correct Answer: C) Fobj.writelines(sequence). ← 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