Problem Statement:
There’s a ticket-selling booth at the cricket stadium from where visitors have to buy tickets and only then, do they get entry. The ticket fare for the concert is Rs. 500. The ticket counter keeps watch on the total amount collected and the number of people who visited the stadium.
Design a class for the ticket counter containing-
- Data members:
- Number of visitors
- Total amount collected
- Member Functions:
- To increment the number of visitors and the total amount.
- To display the total number of visitors and the total amount collected so far.
- Also, initialize the members.
Code for Ticket selling in Cricket Stadium using Python:
class Counter:
#class variables to initialize the members
NoofVisitors = 0
TotalAmount = 0
#function for incrementing the visitors and tolling total amount
def sellticket(self):
#increment the number of visitors
Counter.NoofVisitors +=1
#add the ticket fair to the total amount
Counter.TotalAmount +=500
#function to display total number of visitors and amount collected
def display(self):
#display number of visitors
print("Total Number of Visitors: ", Counter.NoofVisitors)
#display total amount collected
print("Total Amount Collected: ",Counter.TotalAmount)
#test this class
C1 = Counter()
C1.sellticket()
C1.display()
C2 = Counter()
C2.sellticket()
C2.display()
Output: for Ticket selling in Cricket Stadium using Python


Also Read:
- Hyphenate Letters in Python
- Earthquake in Python | Easy Calculation
- Striped Rectangle in Python
- Perpendicular Words in Python
- Composite Number in Python
- Greatest Among Four Numbers in Python
- Reverse the sentence in Python
- Denominations in Python
- Min and max values in an array in JavaScript
- Keyboard events in JavaScript
- Reaching Ground Floor in Python
- Number of Moves in Python
- Starks Adventure in Python
- Neutralization in Python | Assignment Expert
- Free shipping in Python
- Raj has ordered two electronic items Python | Assignment Expert
- First Place in Python
- Triples with Properties in Python
- Nested list Indexing Python
- Team Points in Python
- Two words combination in Python
- ID Card in Python
- Cipher with a key in Python | Assignment Expert
- Multiple of 5 in Python
- Sandglass Star in Python
- Multiple of 3 in Python | Assignment Expert
- Ticket selling in Cricket Stadium using Python | Assignment Expert
- Sum of List Elements in Python
- All possible subsets in Python
- Names and Nicknames in Python