File I/O
Read and write files using context managers.
with open("data.txt", "w") as f: f.write("hello")
with open("data.txt") as f: print(f.read())C# uses using with StreamWriter; JavaScript relies on the fs module.
Practice Questions
Section titled “Practice Questions”- Which Python statement automatically closes a file?
Answer
`with`. - Name the Node.js module for file operations.
Answer
`fs`.