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 "HighScore.txt" FOR WRITE | AOpens a file on storage so the program can save its data there, and the data stays after the program ends | |
| 2score ← 250 | BStores a value in a variable, which is lost when the program ends | |
| 3A program saves a list of names to a file so they are still there the next time it runs | CA file is not deleted when the program closes. It stays on storage, so the data can be read again later. | |
| 4A program reads the saved high score back from storage when it starts again | DWRITEFILE "Names.txt", Name | |
| 5Score ← 250 // The program ends. Next run, the score is still 250 because variables keep their values. | EREADFILE "HighScore.txt", Score | |
| 6// A file is deleted from storage when the program closes, so the data is gone. | FVariables do not keep their values after the program ends. The score must be saved in a file to last. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
file — A file keeps data on storage so it still exists after the program closes, unlike variables. The program can read it back next time it runs, such as a saved high score or a list of names.OPENFILE "HighScore.txt" FOR WRITEOPENFILE "HighScore.txt" FOR WRITE
WRITEFILE "HighScore.txt", Score
CLOSEFILE "HighScore.txt"OPENFILE "HighScore.txt" FOR READ
READFILE "HighScore.txt", Score
CLOSEFILE "HighScore.txt"OPENFILE "Names.txt" FOR WRITE
WRITEFILE "Names.txt", Name
CLOSEFILE "Names.txt"// Next run: get the saved names back
OPENFILE "Names.txt" FOR READ