A brief note on pseudocode, trace tables and testing: the exam style of pseudocode, dry runs, the four kinds of test data and how to find errors, with practice, a program and questions to check yourself.
A brief note on Pseudocode, Trace Tables and Testing. Read it before a test. Try each question at the end before you open its answer.
HighScore), comments after //.Total ← Total + Mark.IF ... THEN ... ELSE ... ENDIF and CASE OF ... OTHERWISE ... ENDCASE.FOR ... TO ... STEP ... NEXT (count-controlled), WHILE ... DO ... ENDWHILE (tests first), REPEAT ... UNTIL (runs at least once).=, <>, <, <=, >, >=, AND, OR, NOT; DIV and MOD for whole-number division.←.Dry-run with simple data and compare with the expected result. Look for a wrong starting value, a wrong operator, a wrong loop limit, a statement in the wrong place or a missing statement. Write the corrected line.
Python has no REPEAT loop, so the program uses while True and leaves the loop with break when the UNTIL condition is true. It prints a row of a trace table on each pass.
= for assignment. Use ←.MOD(31, 7) return?X ← 5, then WHILE X < 5 DO X ← X + 1 ENDWHILE. How many passes does the loop make?Log in to join the discussion.
Loading…