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?
2. What is the home directory?
3. How do you pass a default argument to a function?
4. Which constant is used to position the next I/O operation relative to the current position in fseek() function?
5. What is the extension of a text file?
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?
7. Which file mode will allow reading and writing without truncating existing data?
8. Explain the difference between text files and binary files.
9. What is the output of the following code?file = open('data.txt', 'r')print(file.read())file.close()
10. Which of the following is not a mode for opening files?
11. What is the purpose of the 'open' function in file handling?
12. How can you write to a file in Python?
13. What is the correct way to ensure a file is closed after operations are completed?
14. When a number is divided by 0, ..... is raised
15. Which module in Python is used for reading and writing binary files by converting Python objects into a byte stream and vice versa?
16. What is the expected output of the function add ..... two when called with parameters 2 and 1?
17. What is the difference between positional and keyword arguments?
18. When we open file in writing mode what will happen?
19. ..... keyword is used to insert a module
20. How can you handle exceptions when opening a file in Python?
21. Mode argument is mandatory.
22. What will be the output-f=open('abc.txt', 'a')text="xyz"f.write(text)f.close()
23. What will be the output-f=open('abc.txt', 'w')print(f.name)
24. We need not to close the file if we are opening file with 'with open( ..... ) as ..... block
25. How do you create a cookie in PHP?