Q. What is the correct way to open a file for writing in Python?
β
Correct Answer: (D)
open('file.txt', 'w')
Explanation: The mode `'w'` opens a file for writing. It will overwrite the file if it exists.