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 | |
|---|---|---|
| 1FOR Count ← 1 TO 5 READFILE "Scores.txt", Score OUTPUT Score NEXT Count | ACLOSEFILE is inside the loop, so the file is closed after the first repeat and the other items cannot be read. It should be after NEXT Count. | |
| 2CLOSEFILE "Scores.txt" | BCloses the file once the loop has finished, so it goes after NEXT and not inside the loop | |
| 3Before the loop starts, the file must be opened for reading so READFILE has something to read from | COPENFILE "Scores.txt" FOR READ | |
| 4Items come back in the order they were written, so each READFILE inside the loop gets the next item in the file | DOPENFILE FOR READ is missing before the loop, so the file is never opened and READFILE cannot read from it. Add OPENFILE "Scores.txt" FOR READ first. | |
| 5FOR Count ← 1 TO 5 READFILE "Scores.txt", Score OUTPUT Score CLOSEFILE "Scores.txt" NEXT Count | EReads 5 items from the open file, one on each repeat, and displays each one as it is read | |
| 6FOR Count ← 1 TO 5 READFILE "Scores.txt", Score OUTPUT Score NEXT Count CLOSEFILE "Scores.txt" | FREADFILE "Scores.txt", Score |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
FOR Count ← 1 TO 5 — Repeats READFILE and OUTPUT 5 times to read 5 items from an open file, one per repeat, in the order written. Put CLOSEFILE after NEXT.OPENFILE "Scores.txt" FOR READ
FOR Count ← 1 TO 5
READFILE "Scores.txt", Item// The file holds 5 items
FOR Count ← 1 TO 5
READFILE "Scores.txt", ItemFOR Count ← 1 TO 5
READFILE "Scores.txt", Item
OUTPUT Item READFILE "Scores.txt", Item
OUTPUT Item
NEXT Count OUTPUT Item
NEXT Count
CLOSEFILE "Scores.txt"