Q. 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) : queue.append(Client) def DeleteClient(Client) : queue.remove(Client) queue = [ ] while True : print() print("Enter your choice as per given -") print("1. For insert data Enter 'insert' ") print("2. For delete data enter 'delete' ") print("3. For Exit Enter 'exit' ") print() user = input("Enter your choice:- ") if user == "insert" : Client = input("Enter the Client name :- ") AddClient(Client) elif user == "delete" : if queue == [ ]: print("UnderFlow") else : Client = input("Enter the name of client :- ") queue.remove(Client) else : break print("Now our Queue = ",queue)
Output :-
Enter your choice as per given -
1. For insert data Enter 'insert'
2. For delete data enter 'delete'
3. For Exit Enter 'exit'
Enter your choice:- insert
Enter the Client name :- Path walla
Now our Queue = ['Path walla']
1. For insert data Enter 'insert'
2. For delete data enter 'delete'
3. For Exit Enter 'exit'
Enter your choice:- insert
Enter the Client name :- Path walla
Now our Queue = ['Path walla']
Enter your choice as per given -
1. For insert data Enter 'insert'
2. For delete data enter 'delete'
3. For Exit Enter 'exit'
Enter your choice:- insert
Enter the Client name :- Portal
Now our Queue = ['Path walla', 'Portal']
Enter your choice as per given -
1. For insert data Enter 'insert'
2. For delete data enter 'delete'
3. For Exit Enter 'exit'
Enter your choice:- insert
Enter the Client name :- Computer Portal
Now our Queue = ['Path walla', 'Portal', 'Computer Portal']
Enter your choice as per given -
1. For insert data Enter 'insert'
2. For delete data enter 'delete'
3. For Exit Enter 'exit'
Enter your choice:- delete
Enter the name of client :- Portal
Now our Queue = ['Path walla', 'Computer Portal']
Enter your choice as per given -
1. For insert data Enter 'insert'
2. For delete data enter 'delete'
3. For Exit Enter 'exit'
Enter your choice:- exit
>>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )