← Quiz: Exceptions and Files: all 15 questions
Quiz: Exceptions and Files · Question 3 of 15
What does opening an existing file with mode "w" do?
What does opening an existing file with mode "w" do?
- A.Adds to the end
- B.Erases its contents first
- C.Opens it read-only
- D.Raises an error
Answer & explanation
Correct answer: Erases its contents first
"w" creates or truncates the file. Use "a" to add to the end.
Can you get the rest right without peeking?
Take the timed Quiz: Exceptions and Files quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →