Computer Science
Write AddClient(Client) and DeleteClient(Client) methods in Python to add a new client and delete a client from a list client name, considering them to act as insert and delete operations of the Queue data structure.
Answer
def AddClient(client):
client_name = input("Enter client name: ")
client.append(client_name)
def DeleteClient(client):
if client == []:
print("Queue is empty")
else:
print("Deleted client:", client.pop(0))
client = []
AddClient(client)
AddClient(client)
AddClient(client)
print("Initial Client Queue:", client)
DeleteClient(client)
print("Client Queue after deletion:", client)Output
Enter client name: Rahul
Enter client name: Tanvi
Enter client name: Vidya
Initial Client Queue: ['Rahul', 'Tanvi', 'Vidya']
Deleted client: Rahul
Client Queue after deletion: ['Tanvi', 'Vidya']
Related Questions
A linear Stack called Directory contains the following information as contacts:
— Pin code of city
— Name of cityWrite add(Directory) and delete(Directory) methods in Python to add and remove contacts using append() and pop() operations in Stack.
Write add(Books) and delete(Books) methods in Python to add Books and Remove Books considering them to act as append() and pop() operations in Stack.
Write Addscore(Game) and Delscore(Game) methods in Python to add new Score in the list of score in a game and remove a score from a list of score of a game considering these methods to act as PUSH and POP operation of data structure Stack.
Write a Python program to sort a Stack in ascending order without using an additional Stack.