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
Model answer
What a good answer should say
- The existing contents may be overwritten
Explanation
Why this works
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.
Common mistake
No common mistake is linked to this question yet.
