Exam-style question
Try this first
A student opens a text file using Python's w mode. What is the main risk if the file already contains data?.
- A.The existing contents may be overwritten
- B.The file can only be read, not changed
- C.The file is automatically converted into a binary file
- D.The program can only add data to the end of the file
Answer and explanation
Concise answer
The existing contents may be overwritten
Why this is correct
Opening a text file in w mode allows writing and normally replaces the existing contents. Append mode, a, is used when new data should be added to the end.
Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.
Common mistake
No common mistake is linked to this question yet.
