Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This Designing an algorithm that uses logical operators with selection and iteration worksheet is part of the ACARA Digital Technologies Years 9–10 — Algorithms with Logical Operators 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 | |
|---|---|---|
| 1WHILE attempts < 3 AND NOT loggedIn DO | AIF age < 16 AND day <> "Saturday" THEN price ← 8 | |
| 2UNTIL lives = 0 OR score = 10 | BOR keeps the loop running while attempts are under 3, even after a successful login, or while not logged in, even after 3 failures. It should be AND so both conditions must hold. | |
| 3A ticket price decision uses AND so the child price only applies on a weekday when the person is under 16 | CAND needs both to be true at once, so the game would not end when only lives = 0 or only score = 10. It should use OR. | |
| 4The flowchart and the pseudocode agree when both show the same loop, the same decision and the same AND/OR condition | DThe login loop keeps running only while the user has tries left and has not yet logged in. It stops on either event. | |
| 5WHILE attempts < 3 OR NOT loggedIn DO | EThe game loop stops as soon as either the player runs out of lives or reaches a score of 10. | |
| 6IF lives = 0 AND score = 10 THEN OUTPUT "Game over" | FREPEAT ... IF lives = 0 OR score = 10 THEN stop |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
WHILE + IF + AND/OR/NOT — A complete design where a loop repeats, IF decisions use AND, OR or NOT, and the flowchart and the pseudocode do the same job, so both versions agree.attempts ← 0
WHILE attempts < 3 AND correct = FALSE DO
attempts ← attempts + 1IF age < 13 OR age > 64 THEN
price ← 8
ENDIFREPEAT
score ← score + 1
UNTIL lives = 0 OR score = 10IF age < 18 AND NOT (day = "Sat") THEN
price ← 10
ENDIFWHILE lives > 0 AND score < 10 DO
score ← score + 1
ENDWHILE