Chapter 5: File Handling Solution

1. What is the difference between “w” and “a” modes?

2. What is the significance of file-object?

3. How is file open() function different from close() function?

4. Write statement to open binary file C:\Myfiles\Text1.txt in read and write mode by specifying the file path in two different formats.
file1 = open(“C:\Myfiles\Text1.txt”, “r+”)

5. When a file is opened for output, what happens when
(i) The mentioned file does not exist

Python raises I/O Error

(ii) The mentioned file does exists

File is opened in read only mode

6. What role is played by modes in file operations? Describe the various file mode constants and their meanings.

7. What are the advantages of saving data in:
(i) Binary form
(ii) Text form

8. When do you thing text file should be preferred over binary files?

9. Write a statement in Python to perform the following operations:
(a) To open a text file “BOOK.TXT” in read mode

F = open(“BOOK.TXT”, “r”)

(b) To open a text file “BOOK.TXT” in write mode

F = open(“BOOK.TXT”, “w”)

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!