#STACK OPERATIONS
#program1
def PUSH(ele):
[Link](ele)
print("Element added")
def POP():
if stack==[]:
print("Underflow")
else:
x=[Link]()
print("Element deleted",x)
def PRINT():
if stack==[]:
print("STACK IS EMPTY")
else:
print("STACK CONTAINS")
for i in range(len(stack)-1,-1,-1):
print(stack[i])
#MAIN
stack=[]
PUSH(10)
PUSH(20)
PUSH(30)
PRINT()
POP()
PRINT()
POP()
PRINT()
POP()
PRINT()
#2. program
'''def PUSH(ele):
[Link](ele)
print("Element added")
def POP():
if stack==[]:
print("Underflow")
else:
x=[Link]()
print("Element deleted",x)
def PRINT():
if stack==[]:
print("STACK IS EMPTY")
else:
print("STACK CONTAINS")
for i in range(len(stack)-1,-1,-1):
print(stack[i])
stack=[]
choice=1
while choice<=3:
print("1 FOR INSERTION")
print("2 FOR DELETION")
print("3 FOR PRINTING")
choice=int(input("Enter your choice"))
if choice==1:
ele=int(input("Enter ele"))
PUSH(ele)
elif choice==2:
POP()
elif choice==3:
PRINT()
else:
break
#employee details in a stack
#program 3
'''def PUSH(ele):
[Link](ele)
print("Element added")
def POP():
if emp==[]:
print("Underflow")
else:
x=[Link]()
print("Element deleted",x)
def PRINT():
if emp==[]:
print("STACK IS EMPTY")
else:
print("STACK CONTAINS")
for i in range(len(emp)-1,-1,-1):
print(emp[i])
emp=[]
choice=1
while choice<=3:
print("1 FOR INSERTION")
print("2 FOR DELETION")
print("3 FOR PRINTING")
choice=int(input("Enter your choice"))
if choice==1:
empid=int(input("Enter
empid"))
ename=input("Enter name")
sal=int(input("Enter salary"))
e=[empid,ename,sal]
PUSH(e)
elif choice==2:
POP()
elif choice==3:
PRINT()
else:
break
#program 4
st=[]
top=-1
def PUSH(st,top,ele):
[Link](ele)
top=len(st)-1
print("ele added")
def POP(st,top):
top=len(st)-1
if top==-1:
print("Underflow")
else:
x=[Link]()
print("Ele deleted",x)
top=top-1
def PRINT(st,top):
top=len(st)-1
if top==-1:
print("STACK IS EMPTY")
else:
print("STACK CONTAINS")
for i in range(top,-1,-1):
print(st[i])
choice='1'
while choice:
print("1 FOR INSERTION")
print("2 FOR DELETION")
print("3 FOR PRINTING")
choice=input("Enter your choice")
if choice=='1':
e=int(input("Enter element"))
PUSH(st,top,e)
elif choice=='2':
POP(st,top)
elif choice=='3':
PRINT(st,top)
else:
break