Lesson 2.4 · Trace it
Trace: elif
Python code3 rows to fill2 marks
Complete the trace table for this Python code. [2]
Line 1: n = 75Line 2: if n >= 90:Line 3, indented 1 level: grade = "A"Line 4: elif n >= 70:Line 5, indented 1 level: grade = "B"Line 6: elif n >= 50:Line 7, indented 1 level: grade = "C"Line 8: else:Line 9, indented 1 level: grade = "F"Line 10: print(grade)
Fill in one row each time a line changes n or grade, 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.
| Row | n | grade | output |
|---|---|---|---|
| 1 | |||
| 2 | |||
| 3 |