Press Next Step to start executing the code line by line.
algorithm.py
Trace Table0 rows
number
remainder
total
Output
Rows will appear as code executes…
Variable Watch
NUM—
numberundef
remainderundef
totalundef
✓ Complete — output is 12
0 / 0
Q = NOT S AND T means (NOT S) AND T — the NOT applies only to S, not the whole expression.
Derive S and T by spotting patterns in A, B, C. Then compute Q row by row.
Expression for S
? — click Reveal
Expression for T
? — click Reveal
Given: Q
NOT S AND T
0 / 8 revealed
A
B
C
S
T
Q = NOT S AND T
⚠ Bracket trap: NOT S AND T = (NOT S) AND T.
If S=1 then NOT S = 0, so Q = 0 regardless of T.
If S=0 then Q simply equals T.
Mark Scheme — 3 marks
✓1 mark: S = A AND C (correct logical expression)
✓1 mark: T = B OR C (correct logical expression)
✓1 mark: All 8 Q values correct
✗Common error: writing NOT(S AND T) instead of (NOT S) AND T
▶
Ready — target: 78
Array: [11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 101]. Press Next Step to begin.
Click Next Step to walk through the binary search. The array is sorted so we can halve the search space each time.
⚠ Mid-point rule: Always write the full calculation (start + end) // 2 — the mark scheme awards the working, not just the result.
Integer division floors the result: (6+7)//2 = 6, not 6.5.
Mark Scheme — 6 marks
✓1 mark per correct row (4 rows needed)
✓Mid-point calculation must show the arithmetic, not just the result
✓All Found values must be N (78 is not in the array)
✓Final Discard = "none" — search exhausted, start = end
✗Common error: writing only the result of (start+end)//2, not the full sum
✗Common error: writing "lower" or "higher" on the final row instead of "none"