Date : 04.01.
2022 Program No :17
Problem Definition:
Write an interactive Python program using the functions DoPush(Customer),
DoPop(Customer) and DoShow(Customer) to push,pop and display the
Customer details like Customer ID, Name, Phone no from the Stack of
Customers.
AIM:
To write an interactive Python program using the functions DoPush(Customer),
DoPop(Customer) and DoShow(Customer) to push,pop and display the Customer
details from the Stack of Customers.
Program:
def isempty(stk):
if stk==[]:
return True
else:
return False
def dopush(stk,li):
[Link](li)
top=len(stk)-1
print("Values Inserted")
def dopop(stk):
if isempty(stk):
return "stack is empty"
else:
l1=[Link]()
if len(stk)==0:
top=None
else:
top=len(stk)-1
return l1
def doshow(stk):
if isempty(stk):
print("Stack is empty")
else:
top=len(stk)-1
for a in range(top,-1,-1):
print(stk[a])
stk=[]
top=None
while True:
print("1. Insert Customer Details")
print("2. Delete Customer Details")
print("3. Show all Customer Details")
print("4. Exit ")
ch=int(input("Enter your choice :"))
if ch==1:
li=eval(input("Enter [Link],Name,Phone number as list"))
dopush(stk,li)
elif ch==2:
item=dopop(stk)
if item=="Stack is empty":
print("Under flow... Stack is empty")
else:
print("Deleted item is:",item)
elif ch==3:
doshow(stk)
elif ch==4:
break
else:
print("Wrong choice")
OUTPUT
1. Insert Customer Details
2. Delete Customer Details
3. Show all Customer Details
4. Exit
Enter your choice :1
Enter [Link],Name,Phone number as list[1,'raja',7896541236]
Values Inserted
1. Insert Customer Details
2. Delete Customer Details
3. Show all Customer Details
4. Exit
Enter your choice :1
Enter [Link],Name,Phone number as list[2,'vinoth',5698741236]
Values Inserted
1. Insert Customer Details
2. Delete Customer Details
3. Show all Customer Details
4. Exit
Enter your choice :3
[2, 'vinoth', 5698741236]
[1, 'raja', 7896541236]
1. Insert Customer Details
2. Delete Customer Details
3. Show all Customer Details
4. Exit
Enter your choice :2
Deleted item is: [2, 'vinoth', 5698741236]
1. Insert Customer Details
2. Delete Customer Details
3. Show all Customer Details
4. Exit
Enter your choice :4