Skip to content
Question

Q.Write a statement in Python to open a text file WRITEUP.TXT so that new content can be written in it.

(OR)
Write a statement in Python to open a text file README.TXT so that existing content can be read from it.
CBSECBSE Class XII Board 2019Subjective· 1mImportance★★★★★
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Part (a): open for writing with open("WRITEUP.TXT", "w").

Part (b): open for reading with open("README.TXT", "r").

Part (a)

To write new content into a text file you use write mode, "w". If the file does not exist Python creates it; if it does exist, its contents are truncated (erased) before writing begins.

f = open("WRITEUP.TXT", "w")
``` …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.