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 | |
|---|---|---|
| 1SUBSTRING("Happy Days", 1, 5) | AIF SUBSTRING(ID, 1, 1) = "A" THEN | |
| 2SUBSTRING(Word, 3, 1) | BReturns just the third character of the string stored in Word | |
| 3Take the first 3 characters of a string called Code and store them in Prefix | CPrefix ← SUBSTRING(Code, 1, 3) | |
| 4A format check that tests whether the first character of ID is the letter A | DReturns "Happy": 5 characters starting at position 1, the first character | |
| 5SUBSTRING("Happy Days", 0, 5) | EThe length is the number of characters to take, not an end position. Starting at 7 with length 10 runs past the end of the string | |
| 6SUBSTRING("Happy Days", 7, 10) | FPosition 0 does not exist because the first character is at position 1, so the start value must be 1 |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
SUBSTRING("Happy Days", 1, 5) — SUBSTRING(string, start, length) returns length characters beginning at position start. Position 1 is the first character, so this returns "Happy".SUBSTRING("Happy Days", 1, 5)SUBSTRING("Happy Days", 1, 5)Word ← SUBSTRING("Happy Days", 7, 4)Initial ← SUBSTRING(Name, 1, 1)
OUTPUT InitialIF SUBSTRING(ID, 4, 1) <> "-" THEN
OUTPUT "Invalid format"
ENDIF