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.
Ans:
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
Ans:
Python raises I/O Error
(ii) The mentioned file does exists
Ans:
File is opened in read only mode
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
Ans:
F = open(“BOOK.TXT”, “r”)
(b) To open a text file “BOOK.TXT” in write mode
Ans:
F = open(“BOOK.TXT”, “w”)