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") | AA length check that is true only when the password has at least 8 characters | |
| 2LENGTH(Password) >= 8 | BThe comment is wrong because spaces count as characters. LENGTH("Hi there") returns 8, not 7. | |
| 3Store the number of characters in a name in a variable | CNameSize ← LENGTH(Name) | |
| 4Reject a PIN that does not have exactly 4 characters | DReturns 10, because the space between the two words counts as a character | |
| 5Size ← LENGTH "Cat" | EThe string is not inside brackets. LENGTH is a function, so its argument must be in brackets: LENGTH("Cat"). | |
| 6// LENGTH("Hi there") returns 7 OUTPUT LENGTH("Hi there") | FIF LENGTH(PIN) <> 4 THEN |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
LENGTH(<string>) — Returns the number of characters in a string as an integer, counting spaces. LENGTH("Happy Days") returns 10. Used in length checks.OUTPUT LENGTH("Happy Days")DECLARE Name : STRING
INPUT Name
Size ← LENGTH(Name)IF LENGTH(Password) >= 8 THENOUTPUT LENGTH("Happy Days") // shows 10IF LENGTH(Code) <> 4 THEN
OUTPUT "Wrong length"
ENDIF