Trace it
Trace table: overridden ticket prices
Python code7 rows to fill4 marks
Complete the trace table for this Python code. A museum app sells three kinds of ticket. ChildTicket and GroupTicket are subclasses of Ticket, and each one overrides price. super().price() runs the version of price in the superclass, Ticket. Then answer the question below the table. [4]
Line 1: class Ticket:Line 2, indented 1 level: def price(self):Line 3, indented 2 levels: return 10Line 4:Line 5: class ChildTicket(Ticket):Line 6, indented 1 level: def price(self):Line 7, indented 2 levels: return 6Line 8:Line 9: class GroupTicket(Ticket):Line 10, indented 1 level: def price(self):Line 11, indented 2 levels: return super().price() * 4 - 5Line 12:Line 13: tickets = [Ticket(), ChildTicket(), GroupTicket()]Line 14: total = 0Line 15: for t in tickets:Line 16, indented 1 level: p = t.price()Line 17, indented 1 level: total = total + p
Fill in one row each time a line changes p or total. 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.
| Row | p | total |
|---|---|---|
| 1 | ||
| 2 | ||
| 3 | ||
| 4 | ||
| 5 | ||
| 6 | ||
| 7 |