Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This CASE clauses with ranges and several statements worksheet is part of the IGCSE Computer Science 0478 — 8.1b Sequence, Selection and Iteration journey. Print it as a booklet?
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 | |
|---|---|---|
| 11 TO 9 : | A0 TO 49 : 50 TO 100 : | |
| 270 TO 100 : grade <- "A" OUTPUT grade | BThe ranges overlap because 50 is in both 0 TO 50 and 50 TO 100. The first range should end at 49. | |
| 3A range clause for the grade band 50 to 69 that sets the grade to B | CA CASE clause that matches any value from 1 up to 9, including both 1 and 9 | |
| 4Ranges in the same CASE must not overlap, so each mark belongs to only one band | D50 TO 69 : grade <- "B" | |
| 50 TO 50 : grade <- "F" 50 TO 100 : grade <- "P" | EA range must be written with the keyword TO, not a hyphen. It should be 1 TO 9 : | |
| 6CASE OF mark 1 - 9 : OUTPUT "Low" ENDCASE | FA range clause whose two indented statements both run when the value is between 70 and 100 |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
1 TO 9 : — In a CASE clause, value1 TO value2 matches a whole range, such as 1 TO 9. Indented statements under the clause all run. Ranges in one CASE must not overlap.CASE OF Score
0 TO 49 : OUTPUT "Fail"
ENDCASECASE OF Mark
50 TO 69 : OUTPUT "Merit"
ENDCASECASE OF Mark
1 TO 9 : Total <- Total + Mark
OUTPUT Total 0 TO 49 : Grade <- "F"
50 TO 100 : Grade <- "P"
ENDCASECASE OF Mark
1 TO 9 : OUTPUT "Low"
ENDCASE