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 | |
|---|---|---|
| 1IF IsEven(Number) THEN | AIF IsAdult(Age) THEN | |
| 2WHILE NOT IsPrime(Number) DO | BComparing the BOOLEAN function call with = TRUE is not needed. The call already gives TRUE or FALSE, so it should be IF IsEven(Number) THEN. | |
| 3A function that RETURNS a BOOLEAN can use a comparison as its return value, because a comparison gives TRUE or FALSE. | CRETURN Age >= 18 | |
| 4A BOOLEAN function can be called straight in an IF condition without comparing it to TRUE. | DThe function call is missing its brackets and argument. It should be IF IsAdult(Age) THEN so the function receives a value. | |
| 5IF IsEven(Number) = TRUE THEN | ECalls the BOOLEAN function IsEven straight in the IF condition. The call gives TRUE or FALSE, so the THEN part runs only when it is TRUE. | |
| 6IF IsAdult THEN | FThe loop keeps repeating while the BOOLEAN function IsPrime returns FALSE for Number, because NOT turns FALSE into TRUE. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
IF IsEven(Number) THEN — A function that RETURNS a BOOLEAN can be called straight in an IF or WHILE condition. The call gives TRUE or FALSE, so no comparison is needed.IF IsEven(Number) THEN
OUTPUT "Even"
ENDIFFUNCTION IsAdult(A : INTEGER) RETURNS BOOLEAN
RETURN A >= 18
ENDFUNCTIONFUNCTION IsBig(N : INTEGER) RETURNS BOOLEAN
RETURN N > 100
ENDFUNCTIONWHILE NOT IsValid(Pin) DO
INPUT Pin
ENDWHILEIF IsAdult(Age) THEN
OUTPUT "Welcome"
ENDIF