-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayground.py
More file actions
51 lines (38 loc) · 836 Bytes
/
playground.py
File metadata and controls
51 lines (38 loc) · 836 Bytes
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
class GregStack():
def __init__(self):
self.list = []
def push(self,data):
self.list.append(data)
def peek(self):
return self.list[len(self.list)-1]
def pop(self):
item = self.list.pop(len(self.list)-1)
return item
stk = GregStack()
stk.push("HI")
stk.push("Oh")
print(stk.peek())
print(stk.pop())
print(stk.pop())
class GregQueue():
def __init__(self):
self.list = []
def enque(self, data):
self.list.insert(0, data)
def dequeue(self):
item = self.list.pop(len(self.list)-1)
return item
q = GregQueue()
q.enque("1")
q.enque("2")
print(q.dequeue())
print(q.dequeue())
def string_times(str, n):
x = 0
end = ""
while x < n:
end = end+str
x = x + 1
print(end)
return str
string_times("hi", 4)