by BlastRoom
Practice identifying failures in short pseudocode programs and correcting them.
#computer_science

40 questions
One question set, multiple game modes. Tap any game to see it in action. Not sure which to pick?
Answer to place stones and capture territory.
Outrun the snow together.
Earn blasts, then hunt the other team.
Answer to earn energy, then climb.

The class blasts through walls together.
Bid on mystery lots. Most money wins.
Sell tours. Nice, standard, or a total scam.
Answer, restock, and serve the rush.
More correct answers pulls the rope your way.
Answer, then shoot down the alien wave.
Answer, then tap to leap the frozen ridge.
A register program should subtract a $12.50 purchase from $20, but it displays $32.50 and continues normally. How should this failure be classified?
This program will not start: SET name TO "Mia DISPLAY name The report says, "Line 1: string is missing a closing quotation mark." What kind of error is this?
A program reaches `DISPLAY total / count` when count is 0 and stops with "cannot divide by zero." What kind of error occurred?
A loop is meant to display numbers 1 through 5, but it displays 1 through 6 and then ends normally. What kind of error is this?
This code is reported as `Line 2: expected THEN after condition`: IF temperature > 30 DISPLAY "hot" END IF What type of error is reported?
A program has `SET colors TO ["red", "blue"]` and tries to display `colors[2]`. It displays two colors first, then stops because item 2 does not exist. What kind of error is this?
A counter should total 3, 4, and 5, but the program sets `total TO value` on each loop pass and displays 5. It finishes normally. What type of error is this?
A program accepts a user's age as text and then stops at `SET nextAge TO age + 1` with "cannot add text and integer." What kind of error occurred?
This program is reported as `Line 1: identifier cannot contain a space`: SET test score TO 90 DISPLAY test score What kind of error is this?
A grading program checks `IF score >= 60` before checking `IF score >= 90`. A score of 95 receives "pass" instead of "excellent," and the program ends normally. What kind of error is this?
With scores holding [10, 20, 30], this program should display 20 but displays 60. Which line causes the wrong result? 1 SET total TO 0 2 SET count TO 0 3 FOR EACH s IN scores 4 SET total TO total + s 5 SET count TO 1 6 DISPLAY total / count
A program should calculate 9 minus 4 and display 5, but it displays 13. Which line causes the wrong result? 1 SET first TO 9 2 SET second TO 4 3 SET difference TO first + second 4 DISPLAY difference
List positions start at index 0. This program should display "Ava," the first name, but displays "Ben." Which line causes the error? 1 SET names TO ["Ava", "Ben", "Chen"] 2 SET firstIndex TO 1 3 DISPLAY names[firstIndex]
The program should allow a student to join a trip only when they have a permission form AND payment. A student with only payment is allowed. Which line causes this? 1 SET allowed TO false 2 IF hasForm OR hasPayment THEN 3 SET allowed TO true 4 END IF
The function should return the area of a rectangle 6 by 4, but it returns 10. Which line causes the wrong result? 1 FUNCTION area(length, width) 2 SET result TO length + width 3 RETURN result 4 END FUNCTION
This program should find the largest number in [8, 3, 11], but it displays 3. Which line causes the wrong result? 1 SET largest TO numbers[0] 2 FOR EACH n IN numbers 3 IF n < largest THEN 4 SET largest TO n 5 END IF 6 END FOR 7 DISPLAY largest
A program should display "even" for 14, but it displays "odd." Which line causes the wrong result? 1 SET n TO 14 2 IF n MOD 2 = 1 THEN 3 DISPLAY "even" 4 ELSE 5 DISPLAY "odd" 6 END IF
A program should count four items in a list but displays 5. Which line causes the wrong result? 1 SET count TO 1 2 FOR EACH item IN supplies 3 SET count TO count + 1 4 END FOR 5 DISPLAY count
This program should add 1 through 5 and display 15, but it never stops. Which change fixes it? SET i TO 1 SET total TO 0 REPEAT WHILE i <= 5 SET total TO total + i DISPLAY total
The values 3 and 4 have an average of 3.5, but this program displays 3 because DIV is integer division. Which change fixes it? SET total TO 7 SET count TO 2 DISPLAY total DIV count
This program should add 8 and 5 and display 13, but it displays "085." Which change fixes it? SET total TO "0" SET total TO total + 8 SET total TO total + 5 DISPLAY total
This program should show the average only if scores has items, but it crashes on an empty list. Which change fixes it? SET total TO 0 SET count TO 0 FOR EACH s IN scores SET total TO total + s SET count TO count + 1 END FOR DISPLAY total / count
A program should display every item in a three-item list, but it displays only the first two. Which change fixes it? SET i TO 0 REPEAT WHILE i < LENGTH(items) - 1 DISPLAY items[i] SET i TO i + 1 END REPEAT
This program should label a temperature of 0 as "freezing," but it labels it "above freezing." Which change fixes it? IF temperature >= 0 THEN DISPLAY "above freezing" ELSE DISPLAY "freezing" END IF
A function should return the number after n, but `nextNumber(8)` returns 8. Which change fixes it? FUNCTION nextNumber(n) RETURN n END FUNCTION
What happens when this program runs? SET names TO ["Ana", "Ben"] SET i TO 0 REPEAT 3 TIMES DISPLAY names[i] SET i TO i + 1 END REPEAT
Before it runs, predict the output: SET i TO 0 REPEAT WHILE i < 3 DISPLAY i SET i TO i + 1 END REPEAT
What will this program display? SET score TO 72 IF score >= 80 THEN DISPLAY "advanced" ELSE DISPLAY "developing" END IF
What will this program display? SET n TO 17 DISPLAY n MOD 5
What value is displayed? FUNCTION double(n) RETURN n * 2 END FUNCTION DISPLAY double(4)
Predict the final output: SET total TO 0 FOR EACH n IN [2, 4, 6] SET total TO total + n END FOR DISPLAY total
Scores is an empty list. The program stops with `Error on line 6: cannot divide by zero.` What went wrong? 1 SET total TO 0 2 SET count TO 0 3 FOR EACH s IN scores 4 SET total TO total + s 5 SET count TO count + 1 6 DISPLAY total / count
The program stops with `Error on line 4: list index 3 does not exist.` What caused it? 1 SET days TO ["Mon", "Tue", "Wed"] 2 SET i TO 0 3 REPEAT 4 TIMES 4 DISPLAY days[i] 5 SET i TO i + 1 6 END REPEAT
A program stops with `Error on line 3: cannot convert "twelve" to an integer.` What caused the error? 1 SET enteredAge TO "twelve" 2 SET age TO 0 3 SET age TO INTEGER(enteredAge) 4 DISPLAY age
A program stops with `Error on line 5: variable total has not been assigned.` What caused the error? 1 SET bonus TO 0 2 IF score > 90 THEN 3 SET bonus TO 5 4 END IF 5 DISPLAY total + bonus
A program is meant to display "positive" only for numbers greater than zero, but it uses `IF n >= 0`. Which test input exposes the bug most directly?
A loop should display every item in a list but uses `FOR i FROM 0 TO LENGTH(items) - 2`, where TO includes its end value. Which test input makes it display nothing even though the list has an item to show?
A program should charge free shipping for orders of $50 or more, but it tests `IF orderTotal > 50`. Which test input exposes the bug most directly?
Lists start at index 0. A function should return the last item of a list but uses `RETURN items[LENGTH(items)]`. Why does a test with the list ["a"] fail?
This program should show "freezing" for 0. Does the code below need a correction? IF temperature > 0 THEN DISPLAY "above freezing" ELSE DISPLAY "freezing" END IF
Crack the passcode before the zombies get in.
Answer, then swat bugs for bonus points.
Race through questions at your own speed.
Same question on every screen. Fastest wins.

Pick a tile, answer, hit bonuses and steals.
Python Variables, input() and Type Casting
40 questions