1. Home
  2. Data Science
  3. Python
  4. Which mode opens a file for appending text in Python?

Added 25 Nov 2026

Which mode opens a file for appending text in Python?

  1. 'w'
  2. 'a' Correct answer
  3. 'r'
  4. 'x'

Correct answer

B. 'a'

MCQSEXAM

Explanation

'a' appends to the end; 'w' truncates the file.

Reference

Asked in: Python Interview File Handling

https://docs.python.org/3/tutorial/inputoutput.html

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs