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 | |
|---|---|---|
| 1Counter ← Counter + 1 | AAdds 1 to the current value of Counter and stores the new value back in Counter. In a trace table, write the new value in the Counter column. | |
| 2Remainder ← 17 MOD 5 | BRemainder gets the value 2 because 17 divided by 5 leaves 2. In a trace table, write 2 in the Remainder column. | |
| 3Trace the lines in order and record each variable's new value after every assignment. After Total ← 4 and then Total ← Total * 3, Total is 12. | CThe student used the new value of X (10) to work out Y. Y was assigned when X was 5, so Y stays 7. Changing X later does not change Y. | |
| 4To trace DIV and MOD, work out each result on its own line. Starting with Number ← 47, Tens ← Number DIV 10 stores 4 and Units ← Number MOD 10 stores 7. | DThe student only recorded one of the two additions. Counter goes 0, then 1, then 2, so the output is 2, not 1. Every assignment needs its own new value in the trace table. | |
| 5Counter ← 0 Counter ← Counter + 1 Counter ← Counter + 1 OUTPUT Counter // A student traces the output as 1 | ETotal ← 4 Total ← Total * 3 OUTPUT Total | |
| 6X ← 5 Y ← X + 2 X ← 10 OUTPUT Y // A student traces the output as 12 | FNumber ← 47 Tens ← Number DIV 10 Units ← Number MOD 10 |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
trace table — A table with one column per variable. Follow the program line by line and write each variable's new value after every assignment, so you can predict the final OUTPUT.Counter ← 0
Counter ← Counter + 1
OUTPUT Counter // shows 1Counter ← 3
Counter ← Counter + 1
Counter ← Counter + 1 // now 5Total ← 17
Tens ← Total DIV 10 // 1
Units ← Total MOD 10 // 7Total ← 17
Units ← Total MOD 5
OUTPUT Units // shows 2A ← 4
B ← A * 2
A ← B + 1 // A is now 9