Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Queue
- data=""
- myQueue=["a","b","c","d","","",""]
- pointerTop=3
- pointerBottom=0
- queueMax=len(myQueue)-1
- def push():
- global myQueue
- global pointerTop
- global pointerBottom
- global data
- global queueMax
- data=input("Enter your Data!: ")
- if pointerTop==queueMax:
- print("Sorry this queue is full!")
- else:
- pointerTop=pointerTop+1
- myQueue[pointerTop]=data
- print("Data Saved!")
- print(myQueue)
- def pop():
- global myQueue
- global pointerTop
- global pointerBottom
- global data
- global queueMax
- myQueue[pointerBottom]=""
- print("Data Deleted")
- pointerBottom=pointerBottom+1
- print(myQueue)
- while 1:
- print(pointerTop,pointerBottom)
- choice=input("PUSH or POP?: ")
- if choice=="POP":
- pop()
- elif choice=="PUSH":
- push()
- else:
- print("INVALID INPUT")
- print("===================================")
Add Comment
Please, Sign In to add comment