FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
PythonLearning/57.QueueInPython.py at Pythontuts · aditya0035/PythonLearning · GitHub
aditya0035
/
PythonLearning
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
PythonLearning
/
57.QueueInPython.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
41 lines (37 loc) · 1.02 KB
Breadcrumbs
PythonLearning
/
57.QueueInPython.py
Copy path
File metadata and controls
41 lines (37 loc) · 1.02 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
"""
Queue in python are the based on the principle of first in and last out
so in queue from one end value get inserted and from other end value are removed
operation used are
1.pop
2.Append
Dequeue: Dequeue is the double ended queue that is in which from one end value are get inserted
and from other end value are removed but this work from both end
operation that works
1.append(add element from left end)
2.pop(remove element from left end)
3.appendleft
4.popleft
"""
class
Queue
:
def
__init__
(
self
):
self
.
queue
=
[]
def
append
(
self
,
value
):
self
.
queue
.
append
(
value
)
def
pop
(
self
):
if
len
(
self
.
queue
)
==
0
:
pass
else
:
self
.
queue
.
pop
(
0
)
def
__len__
(
self
):
return
len
(
self
.
queue
)
def
__getitem__
(
self
,
item
):
return
self
.
queue
[
item
]
my_queue
=
Queue
()
my_queue
.
append
(
"Aditya"
)
my_queue
.
append
(
"Saraswat"
)
for
item
in
my_queue
:
print
(
item
)
my_queue
.
pop
()
my_queue
.
pop
()
for
item
in
my_queue
:
print
(
item
)
Back
|
FazBrowse Home
|
New Git URL