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 | |
|---|---|---|
| 1OPENFILE "Scores.txt" FOR WRITE | ACreates Scores.txt if it does not exist; if it does exist, all the old data in it is erased | |
| 2OPENFILE "Log.txt" FOR WRITE (run a second time) | BWipes everything saved in Log.txt by the first run, so only new data will be there | |
| 3If no file called Names.txt exists, opening it for WRITE makes a new empty file with that name | COpening Scores.txt for WRITE erases the 50 saved scores, leaving only NewScore. The old data should have been read or copied first. | |
| 4To keep the old data in Scores.txt, read it first (READ mode) before opening the file for WRITE | DThe programmer wrongly thinks Day2Text will be added after the Day 1 data. Opening for WRITE deletes the Day 1 data first. | |
| 5// Scores.txt holds 50 saved scores OPENFILE "Scores.txt" FOR WRITE WRITEFILE "Scores.txt", NewScore | EOPENFILE "Names.txt" FOR WRITE | |
| 6// Day 1 data is saved in Diary.txt OPENFILE "Diary.txt" FOR WRITE WRITEFILE "Diary.txt", Day2Text | FOPENFILE "Scores.txt" FOR READ |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
OPENFILE "Scores.txt" FOR WRITE — Opens a file for writing. A new file is created if none exists. If it does exist, all its old data is erased and replaced, so check before overwriting data you need.OPENFILE "Scores.txt" FOR WRITEOPENFILE "Scores.txt" FOR WRITEOPENFILE "Log.txt" FOR WRITE
WRITEFILE "Log.txt", "Day 1"
CLOSEFILE "Log.txt"OPENFILE "New.txt" FOR WRITEScore ← 50
OPENFILE "Scores.txt" FOR WRITE
WRITEFILE "Scores.txt", Score