πŸ“Š Python
Q. What is the correct way to open a file for writing in Python?
  • (A) open('file.txt', 'r')
  • (B) open('file.txt', 'x')
  • (C) open('file.txt', 'a')
  • (D) open('file.txt', 'w')
πŸ’¬ Discuss
βœ… Correct Answer: (D) open('file.txt', 'w')

Explanation: The mode `'w'` opens a file for writing. It will overwrite the file if it exists.

Explanation by: Mr. Dubey
The mode `'w'` opens a file for writing. It will overwrite the file if it exists.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
168
Total Visits
πŸ“½οΈ
8 mo ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
99%
Success Rate