Question: Use only Python Programming for this question. 7. You are assigned a task to create a simulation of a ticket counter with 4 staff selling

Use only Python Programming for this question.
7. You are assigned a task to create a simulation of a ticket counter with 4 staff selling some sort of tickets. The staffs will keep on selling until they ran out of tickets. Here are some descriptions of your task: o Create a function ticket_seller with one parameter lock and contains its own counter for how many tickets that it has sold. o Your function will keep on selling until no more tickets are available. Add in a sleep and randint function to simulate a blocking situation anywhere between 0 and 2 seconds, you can use time. sleep (random.randint(0,2)). o Try to acquire the lock within the function and check if any tickets are still available. If tickets available is less than or equal to 0, your ticket_seller will stop working. If greater than 0, then increment the number of tickets the individual seller has sold and decrease the tickets available by 1. Then print the progress "Seller {name}: Sold one ({tickets available} Left)" and release the lock. o When no more tickets available to sell, print out the total that each seller has sold "Seller {name} sold {tickets_sold) in total." Use the driver code below to test your ticket_seller function: 1 2. 3 4 5 6 if name__ == "__main_": lock = threading. Lock tickets available = 10 7 8 9 10 11 sellers = [] for i in range (4): t = threading.Thread(target=ticket_seller, name=str(i), args= (lock,)) sellers.append(t) t.start 12 13 14 15 16 for seller in sellers: seller.join()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
