Bird
0
0

Which statement about file modes in Python is TRUE?

hard📝 Conceptual Q10 of 15
Python - Standard Library Usage
Which statement about file modes in Python is TRUE?
AOpening a file in 'a' mode overwrites the file content
BOpening a file in 'w' mode appends data to the end
COpening a file in 'r' mode allows writing to the file
DOpening a file in 'x' mode creates a new file and errors if it exists
Step-by-Step Solution
Solution:
  1. Step 1: Review file modes meanings

    'w' overwrites, 'a' appends, 'r' reads only, 'x' creates new file and errors if exists.
  2. Step 2: Identify the true statement

    Only option about 'x' mode is true; others incorrectly describe modes.
  3. Final Answer:

    'x' mode creates new file and errors if exists -> Option D
  4. Quick Check:

    'x' mode = create new file only [OK]
Quick Trick: Use 'x' to create new file, error if exists [OK]
Common Mistakes:
  • Thinking 'w' appends
  • Assuming 'r' allows writing
  • Confusing 'a' with overwrite

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes