Quick Print – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
siteicon
Solved Problem Solved Problem#PYTHON#6130

Problem Statement - B03C-2018

Write AddClient(Client) and DeleteCleint(Client) methods in python to add a new Client and delete a Client from a List of Client Names, considering them to act as insert and delete operations of the queue data structure.

Solution

def AddClient(Client):
    C=raw_input("Client name: ")
    Client.append(C)
def DeleteClient(Client):
    if (Client==[]):
        print "Queue empty"
    else:
        print Client[0],"Deleted"
        del Client[0] # OR Client.pop(0)
OR
class queue:
    Client=[]
    def AddClient(self):
        a=raw_input("Client name: ")
        queue.Client.append(a)
    def DeleteClient(self):
        if (queue.Client==[]):
            print "Queue empty"
        else:
            print queue.Client[0],"Deleted"
            del queue.Client[0]