CBSE Class 12 Computer Science Question 84 of 145

File Handling — Question 1

Back to all questions
1
Question

Question 1

What is the difference between "w" and "a" modes ?

Answer

The differences between "w" and "a" modes are:

"w" mode"a" mode
The "w" mode in file opening is used for writing data to a file.The "a" mode in file opening is used for appending data to a file.
If the file exists, Python will truncate existing data and over-write in the file.If the file exists, the data in the file is retained and new data being written will be appended to the end of the file.