Bird
Raised Fist0

What does opening a file with mode 'a' in Python do?

easy🧠 Conceptual Q11 of Q15
Python - File Handling Fundamentals
What does opening a file with mode 'a' in Python do?
AIt opens the file for reading only.
BIt opens the file and deletes all existing content before writing.
CIt opens the file to add new data at the end without deleting existing content.
DIt creates a new file and writes data only if the file does not exist.
Step-by-Step Solution
Solution:
  1. Step 1: Understand file modes in Python

    Mode 'a' stands for append mode, which means adding data at the end of the file.
  2. Step 2: Compare with other modes

    Unlike 'w' mode which overwrites, 'a' keeps old data and adds new data after it.
  3. Final Answer:

    It opens the file to add new data at the end without deleting existing content. -> Option C
  4. Quick Check:

    Append mode = add data at end [OK]
Quick Trick: Append mode 'a' adds data without erasing old content [OK]
Common Mistakes:
MISTAKES
  • Confusing 'a' with 'w' which overwrites file
  • Thinking 'a' opens file for reading only
  • Assuming 'a' creates a new file only if missing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes