Recall & Review
beginner
What does 'overwrite' mean when saving data to a file in Python?
Overwrite means replacing the entire content of the file with new data, erasing what was there before.
Click to reveal answer
beginner
What does 'append' mean when saving data to a file in Python?
Append means adding new data to the end of the existing file content without removing what was already there.
Click to reveal answer
beginner
Which file mode in Python opens a file for overwriting?
The 'w' mode opens a file for writing and overwrites existing content.
Click to reveal answer
beginner
Which file mode in Python opens a file for appending?
The 'a' mode opens a file for appending, so new data is added at the end.
Click to reveal answer
beginner
What happens if you open a file in 'w' mode and the file does not exist?
Python creates a new empty file before writing, so you can save data even if the file was missing.
Click to reveal answer
What does opening a file with mode 'a' do?
✗ Incorrect
Mode 'a' appends data to the end of the file without deleting existing content.
If you want to replace all content in a file, which mode should you use?
✗ Incorrect
Mode 'w' opens the file for writing and overwrites existing content.
What happens if you open a file in 'w' mode and write data?
✗ Incorrect
Opening in 'w' mode erases existing content and writes new data.
Which mode will create a new file if it does not exist?
✗ Incorrect
Both 'w' and 'a' modes create a new file if it does not exist.
To keep old data and add new lines at the end, which mode is best?
✗ Incorrect
Mode 'a' appends new data without removing old data.
Explain the difference between overwrite and append behavior when writing to files in Python.
Think about what happens to old data in each case.
You got /4 concepts.
Describe what happens when you open a file in 'w' mode versus 'a' mode and write data.
Focus on how the file content changes.
You got /4 concepts.