Lesson 5.3 · Trace it
Trace: case and replace
Python code4 rows to fill4 marks
Complete the trace table for this Python code. word.upper() gives back the text in capital letters. word.replace("o", "a") gives back the text with each o changed to an a. Then answer the question below the table. [4]
Line 1: word = "robot"Line 2: loud = word.upper()Line 3: word.replace("o", "a")Line 4: print(loud)Line 5: print(word)
Fill in one row each time a line changes word or loud, 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 | word | loud | output |
|---|---|---|---|
| 1 | |||
| 2 | |||
| 3 | |||
| 4 |