Question:medium

Which of the file modes in the following is invalid for a text-file?

Show Hint

In Python, file modes like 'a', 'w', and 'r' are for text files, while 'b' is added for binary files (e.g., 'ab' or 'rb').
Updated On: Feb 13, 2026
  • a
  • w
  • r
  • ab
Show Solution

The Correct Option is D

Solution and Explanation

In Python, the "a" mode opens a file for appending, and "w" mode opens a file for writing. "r" is for reading. The "ab" mode is valid only for binary files, not for text files. Therefore, the correct answer is "ab" for text files.
Was this answer helpful?
0