PROGRAM:
import array#importing array module
#creating class for stack
class st:
def __init__(self,size):
[Link]=[Link]('i',[])#declaring the idlicooker
[Link]=-1#taking papper and writing the no of plates as -1
[Link]=size #maximum no of plates in cooker
def push(self,var):#declaring the brother motu to take plate
if [Link]==[Link]-1:
print('stack is full')
else:
[Link]=[Link]+1#increasing the no of plates
[Link](var)#placing the plate into the cooker
def pop(self):#declaring another brother patlu to give plate
if [Link]==-1:
print('stack is empty')
else:
var=[Link][[Link]]#transfering the value in idle plate into
hotbox
[Link]=[Link]-1#decreasing the top value
return var#returing the hotbox to hall
def display(self):#asking assit1 to tell details for cooker
if [Link]==-1:
print('stack is empty')
else:
print('showing the values in stack')
for i in range([Link],-1,-1):
print([Link][i])
def peek(self):#asking assit2 to see and tell about top plate
if [Link]==-1:
print('stack is empty')
else:
print('the top value is',[Link][[Link]])
#this is main(this is hall)
s1=st(5)#declaring the object of cooker
[Link](10)
[Link](20)
[Link]()
[Link]()#calling assit1 to tell details for cooker
output: