1.
What is the difference between read() and readlines()?
Ans. The read() method reads all contents from a file and return it in the same format (string form) as it is written. while readlines() reads the all contents from a file and returns a list of all lines in the file.
2.
What is the difference between readline() and readlines()?
Ans. readline() reads one line at a time from the file while readlines() reads all the lines from the file and returns a list.
3.
What is the significance of file object?
Ans. File objects are used to read and write data to a file on disk. A file object is a refrence to file on the disk. It opens and makes available for different tasks.
4.
When a file is opended for output in append mode, what happends when
(i) the mentioned file does not exist
(ii) the mentioned file exist.
Ans. (i) if the file does not exist then Python will create a new file with specified name and entered data will be written to the file.
(ii) IF the file exists then the file pointer is places at the end of the file and the entered data is append to the file.
5.
what is the difference between binary file and text file?
Ans. A text file stores the data in a string format and it is in human readable form. No translation is done while reading from and writing onto a text file. while binary files stores data in the form of bytes. Translation of data is done while reading and writing data in binary files.