Skip to content
ExamSpine

Lesson 2.7 · Trace it

Trace: and or

Python code6 rows to fill2 marks

Complete the trace table for this Python code. [2]

Line 1: a = 5
Line 2: b = 12
Line 3: if a > 3 and b < 10:
Line 4, indented 1 level: c = 1
Line 5: else:
Line 6, indented 1 level: c = 0
Line 7: if a > 3 or b < 10:
Line 8, indented 1 level: d = 1
Line 9: else:
Line 10, indented 1 level: d = 0
Line 11: print(c)
Line 12: print(d)

Fill in one row each time a line changes a, b, c or d, or prints something. The table already has the right number of rows. In each row, write only what that line changes; you can leave the other cells empty or copy their values down. Write values the way Python shows them: 3 and 3.0 are different, and text goes in quotes. In the output column, write exactly what appears on screen, with no quotes around it.

Rowabcdoutput
1
2
3
4
5
6