Question:

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: Apr 24, 2025
  • a
  • w
  • r
  • ab
Hide Solution
collegedunia
Verified By Collegedunia

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
0