Class 11 Computer Science Chapter 6 File Handling Quiz 34 (25 MCQs)

Quiz Instructions

Select an option to see the correct answer instantly.

1. The output sent to the file is appended to it.
2. File is created if does not exist. If the file exists, file is truncated( past data is lost). Both reading and writing operation can take place. What is the text file mode?
3. What does the 'read()' function do?
4. Which method is used to set the file handle's position within a file?
5. Which function is used to count or display words from a file?
6. File.seek(0) followed by file.read() will:
7. What is the primary purpose of the close operation in file handling?
8. What is the first file handling operation mentioned in the text?
9. What does the 'open' command do in Python file handling?
10. What will be the output of the following code?def add(a, b):return a + bprint(add(5, 7))
11. Which method is used to read the entire contents of a file in Python?
12. What will be the output of the following C code#include union temp \{ int a; float b; char c; \}; int main() \{ union temp s = \{1, 2.5, 'A'\}; printf("%c", s.c); return 0; \}
13. What is the function used to read from a file in Python?
14. How can you read from a file in Python?
15. What is the function used to check if a file exists in Python?
16. What is the significance of the 'rb' mode when opening a binary file?
17. What does the 'readlines' method do in Python file handling?
18. To read 4th line from text file, which of the following statement is true?
19. What is the significance of file modes in file handling?
20. Which one of these variables has an illegal name?
21. What does the os.path.isfile() function return if the file does not exist?
22. Which of the following modes allows both reading and writing to a file?
23. Ravi opened a file in a certain mode. After opening the file, he forgot the mode. One interesting fact about that mode is '' If the file already exists, all the contents will be overwritten" . Help him to identify the correct mode.
24. What is the index of the last character in a string?
25. What are some common use cases for binary files in programming?