Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Am Trying to add button for the program, back links URL

Below program is to input the values and exit the input values in a queue order.

*Requirement *

*i Want the button to make decision making. : do = input('What would you like to do? ').split()

*i Want the button to input the values. : def enqueue(self, data): self.items.append(data)

*i want the button to see the exited values. : def dequeue(self): return self.items.pop(0)

****OUT PUT:****

Step1: Program should show "What would you like to do?" and should give 2 buttons 1. Enqueue 2.dequeue
Step2: when i click Enqueue -- should give me a option to input the data. Step3: when i click Dequeue -- should give me a result of what is data that is getting out.

' class Queue:
    def __init__(self):
        self.items = []

    def is_empty(self):
        return self.items == []

    def enqueue(self, data):
        self.items.append(data)

    def dequeue(self):
        return self.items.pop(0)


q = Queue()
while True:
    print('enqueue <value>')
    print('dequeue')
    print('quit')
    do = input('What would you like to do? ').split()

    operation = do[0].strip().lower()
    if operation == 'enqueue':
        q.enqueue(int(do[1]))
    elif operation == 'dequeue':
        if q.is_empty():
            print('Queue is empty.')
        else:
            print('Dequeued value: ', q.dequeue())
    elif operation == 'quit':
        break '

Comments