# initializing empty myQueue
myQueue = list()
# index stores the shuttle number
index = 0
# functions that define operation of the queue data structure
def enqueue(myQueue, element):
myQueue.append(element)
def isEmpty(myQueue):
if len(myQueue)==0:
return True
else:
return False
def dequeue(myQueue):
if not (isEmpty(myQueue)):
return myQueue.pop(0)
else :
return "Box is empty"
def size(myQueue):
return len(myQueue)
# infinite loop so that it continues as many times the user wants
while(True):
# display the menu to the user
print("Menu")
print("1. Insert a shuttlecock 2. Remove a shuttlecock 3. Display number of shuttlecock 4.exit ")
choice = int(input("Enter your choice"))
# if usre enters 1 then do this
if choice == 1:
index+=1
enqueue(myQueue,index)
print("Shuttle added")
continue
elif choice == 2:
removedshuttle = dequeue(myQueue)
print("The shuttle removed is : ",removedshuttle)
continue
elif choice == 3:
print("The number of shuttles in the box = ",size(myQueue))
continue
elif choice == 4:
break
else:
print("Wrong choice.")