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 | |
|---|---|---|
| 1LENGTH("Happy Days") | AName ← "Sam Lee" OUTPUT LENGTH(Name) | |
| 2LENGTH("") | BSpaces do count as characters, so LENGTH("Hi there") is 8. Do not subtract 1 for the space. | |
| 3LENGTH gives a whole number, so its result can be stored in an INTEGER variable | CDECLARE Size : INTEGER Size ← LENGTH("Cambridge") | |
| 4LENGTH counts the characters of the string held in a variable | DThe string literal has no quotation marks. It should be LENGTH("Happy Days"). | |
| 5Size ← LENGTH(Happy Days) | EReturns 10, because the space between the words counts as a character | |
| 6OUTPUT LENGTH("Hi there") - 1 // student expects 7 because spaces do not count | FReturns 0, because an empty string has no characters |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
LENGTH(Text) — Returns an INTEGER: the number of characters in the string, including spaces. LENGTH("Happy Days") returns 10 and LENGTH("") returns 0.Size ← LENGTH("Happy Days")DECLARE Total : INTEGER
Total ← LENGTH("Happy Days")
OUTPUT TotalCount ← LENGTH("")
OUTPUT Count
// Output: 0Name ← "Ava Lee"
Size ← LENGTH(Name)
OUTPUT SizeSize ← LENGTH("Happy Days")
OUTPUT Size
// Output: 10