← Back to Classes
Question 514
Numbered Tickets
Numbered Tickets
Write the whole Ticket class so every ticket gets the next number in sequence. A class attribute next_number starts at 1; the constructor takes an event name, stores it, copies Ticket.next_number into the object attribute number, and then adds one to Ticket.next_number so the following ticket gets the next value; describe() prints Ticket <number>: <event>. Do NOT write a main block or any top-level test code; the tests construct the class. Input: one line, a whole number, which the tests read and use to create that many tickets for the event Concert, calling describe on each in order and finally printing Ticket.next_number.
Expected Output:
Ticket 1: Concert Ticket 2: Concert Ticket 3: Concert 4
= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Classes
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.