FILE HANDLING
FILE HANDLING
A file is a storage unit in a computer used to store data persistently. It allows data to be
saved even after the program execution ends, making it accessible for future use. Files can
contain various types of information such as text, images, videos, or binary data.
Need for Files in Python:
In Python, files are essential for several reasons:
1. Data Persistence: Files allow long-term storage of data, unlike variables which lose data
when the program ends.
2. Data Sharing: Files enable easy sharing of information between different programs and
systems.
3. Large Data Handling: When data is too large to fit into memory, it can be stored and
processed in files.
4. Logging Purposes: Applications often log events and errors into files for tracking and
debugging.
5. Configuration Storage: Programs often use files to store settings and preferences.
3. State the difference between Write and append mode in opening a file in
python.
Example: