Stack
Aim: To create a stack and use functions related to stack
Requirement: Python IDE
Code:
stack = [ ]
[Link](1)
[Link](2)
[Link](3)
[Link](4)
[Link](5)
print(stack)
print([Link]())
print([Link]())
print([Link]())
def size(a):
return len(a)
def empty(a):
if len(a)==0:
print("The stack is empty")
else:
print("The stack is not empty")
empty(stack)
print(size(stack))
Output:
Results: Push and Pop function was used to add and remove elements in stacks. Len and isEmpty
functions were defined to find out size and to check whether the stack is empty or not.