Bird
0
0

What does the mode 'r' mean when opening a file with open() in Python?

easy📝 Conceptual Q11 of 15
Python - Standard Library Usage
What does the mode 'r' mean when opening a file with open() in Python?
AOpen the file for reading only
BOpen the file for writing only
COpen the file for appending data
DCreate a new file or overwrite existing
Step-by-Step Solution
Solution:
  1. Step 1: Understand file modes in Python

    The mode 'r' stands for reading the file only, meaning you can read data but not change it.
  2. Step 2: Compare with other modes

    Modes like 'w' are for writing (which overwrites), and 'a' is for appending. 'r' does not allow writing.
  3. Final Answer:

    Open the file for reading only -> Option A
  4. Quick Check:

    Mode 'r' = read only [OK]
Quick Trick: Remember 'r' means read, 'w' means write, 'a' means append [OK]
Common Mistakes:
  • Confusing 'r' with 'w' or 'a'
  • Thinking 'r' creates a new file
  • Trying to write to a file opened with 'r'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes