Ticket selling in Cricket Stadium using Python | Assignment Expert

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()

C2 = Counter()

Output: for Ticket selling in Cricket Stadium using Python

code for Ticket selling in Cricket Stadium using Python

Also Read:


Author: Harry

Hello friends, thanks for visiting my website. I am a Python programmer. I, with some other members, write blogs on this website based on Python and Programming. We are still in the growing phase that's why the website design is not so good and there are many other things that need to be corrected in this website but I hope all these things will happen someday. But, till then we will not stop ourselves from uploading more amazing articles. If you want to join us or have any queries, you can mail me at admin@copyassignment.com Thank you