Trace tables
A trace table records every variable at each step, to check the algorithm works.
| Pass | n | n > biggest? | biggest after |
|---|---|---|---|
| 1 | 7 | No | 7 |
| 2 | 3 | No | 7 |
| 3 | 12 | Yes | 12 |
| 4 | 5 | No | 12 |
Output: 12. Correct.
Topic 11 Algorithms
KS3 Computing · An algorithm is a precise, step-by-step plan to solve a problem. Computational thinking turns a messy problem into one. Every algorithm is built from just three things: sequence, selection and iteration.
Topic 13 Programming basics
KS3 Computing · A program stores information in variables, works on it with operators, and controls the order with sequence, selection and iteration. Examples are in Python, with Scratch alongside for Year 7.
Programming Computational ThinkingCambridge Lower Secondary Computing 0860
Say each word, then read what it means. Every one is in the glossary too.
Read it here, or open the study page below to go one step at a time with things to try.
A trace table records every variable at each step, to check the algorithm works.
| Pass | n | n > biggest? | biggest after |
|---|---|---|---|
| 1 | 7 | No | 7 |
| 2 | 3 | No | 7 |
| 3 | 12 | Yes | 12 |
| 4 | 5 | No | 12 |
Output: 12. Correct.
for i in range(5):
print("Lap", i)Prints Lap 0 to Lap 4. range(5) gives 0, 1, 2, 3, 4: it starts at 0 and stops before 5.
Scratch: 'repeat 5'.
password = ""
while password != "dragon":
password = input("Password: ")
print("Access granted")Repeats while the condition is true. As soon as the user types dragon, the loop ends.
If the condition can never become false, it loops for ever: an infinite loop.
Open the study page and go one step at a time.
One question at a time. The reason shows after each answer.