Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1shutil.copy("notes.txt", "backup/notes.txt") | ABuilds a timestamp string such as 20260315_143005 to put in a backup file name. | |
| 2datetime.now().strftime("%Y%m%d_%H%M%S") | BCopies the file notes.txt into the backup folder, leaving the original file in place. | |
| 3List every file in the folder so the script can loop over them and back each one up. | CThe arguments are the wrong way round. The destination is given first and the source second, so the copy goes from the backup folder back to the original, not into the backup. | |
| 4Catch an error, such as a missing file, so the backup script prints a message instead of crashing. | Dexcept FileNotFoundError: | |
| 5shutil.copy("backup/a.txt", "a.txt") | Efor name in os.listdir("docs"): | |
| 6newName = "backup/report.txt" shutil.copy("report.txt", newName) | FThe backup name has no timestamp, so every run writes to the same name and overwrites the previous backup. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
shutil.copy(src, dst) — Python call that copies a file to a backup folder. Put a datetime timestamp in the new name so old backups are not overwritten, and a scheduler can then run the script.import shutilshutil.copy(src, dst)for name in os.listdir("reports"):ts = datetime.now().strftime("%Y%m%d")try:
shutil.copy(src, dst)
except FileNotFoundError: