-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue_basic.py
More file actions
67 lines (58 loc) · 1.42 KB
/
queue_basic.py
File metadata and controls
67 lines (58 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from time import sleep
def create_queue():
queue = []
return queue
def enqueue():
while True:
element = input("Enter Element to Enqueue : ")
if element == "":
break
queue.append(int(element))
def dequeue():
sleep(0.5)
while True:
if not queue:
print("Queue is Empty")
break
else:
p = queue.pop(0)
sleep(0.2)
print(p," is removed from Queue")
sleep(0.5)
print(queue)
sleep(0.5)
proceed = input("Do you want to Dequeue further(Y/N): ").upper()
if proceed in ['Y','YES']:
continue
else:
break
def display():
print(queue)
def quit():
sleep(0.5)
print("\nTHANK YOU")
sleep(0.5)
def final_display():
print("\nFinal Queue: ",queue)
queue = create_queue()
while True:
choice = int(input("\nPlease Select the Operation\n\t1.ADD\n\t2.REMOVE\n\t3.SHOW\n\t4.QUIT\n"))
if choice == 1:
enqueue()
elif choice == 2:
dequeue()
elif choice == 3:
display()
elif choice == 4:
quit()
break
else:
print("Invalid Operation")
sleep(0.5)
proceed = input("\nDo you want to proceed further operations(Y/N): ").upper()
if proceed in ['Y','YES'] :
continue
else:
sleep(0.5)
final_display()
break