-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueue00.py
40 lines (40 loc) · 1.01 KB
/
queue00.py
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
class Stack_from_Queue:
def __init__(self):
self.queue = []
def isEmpty(self):
if self.queue == []:
print("Queue is Empty")
else:
print("Queue is not empty")
def enqueue(self,element):
self.queue.insert(0,element)
def dequeue(self):
return self.queue.pop()
def size(self):
print("size of queue is",len(self.queue))
def pop(self):
for i in range(len(self.queue)-1):
x=self.dequeue()
print(x)
self.enqueue(x)
print("element removed is",self.dequeue())
sq=Stack_from_Queue()
sq.isEmpty()
print("instering element apple")
sq.enqueue("apple")
print("instering element banana")
sq.enqueue("banana")
print("instering element orange")
sq.enqueue("orange")
print("instering element 0")
sq.enqueue("0")
print("The queue elements are as follows:")
print(sq.queue)
print("check if queue is empty?")
sq.isEmpty()
print("remove the last in element")
sq.pop()
sq.pop()
sq.pop()
sq.pop()
sq.isEmpty()