-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack1.py
More file actions
38 lines (29 loc) · 738 Bytes
/
Copy pathStack1.py
File metadata and controls
38 lines (29 loc) · 738 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
class Stack (object):
def __init__(self):
self.items = [ ]
def isEmpty (self):
return self.items == [ ]
def push (self, item):
self.items.append (item)
def pop (self):
return self.items.pop ()
def peek (self):
return self.items [len(self.items)-1]
def size (self):
return len(self.items)
##################################################
def main():
print("Running Stack1.py")
myStack = Stack()
print(myStack.isEmpty())
myStack.push("cat")
myStack.push(4)
print(myStack.peek())
myStack.push(False)
print(myStack.size())
print(myStack.isEmpty())
myStack.push(98.6)
print(myStack.pop())
print(myStack.pop())
print(myStack.size())
main()