Program 1
Program:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 18 08:59:42 2025
@author: seniorlab
"""
flight=[]
def push():
f1= int(input("Enter flight no. : "))
f2 =input("Enter flight name: ")
fare=int(input("Enter flight fare: "))
s=(f1,f2,fare)
[Link](s)
def pop():
if flight == []:
print("Stack underflow")
else:
x=[Link]()
print("Rec deleted", x)
def peek():
if flight == []:
print("stack under flow", )
else:
x=flight[-1]
print("record on top", x)
def display():
if flight == []:
print ("stack underflow")
else:
top =len(flight)-1
for i in range (top,-1,-1):
print (flight[i])
print ("1. Add Record")
print("2. Delete Record")
print("3. Search Record")
print("4. Show All Record ")
print("5. Exit")
while True :
l=int(input("Enter your choice: "))
if l == 1:
push()
elif l == 2:
pop()
elif l == 3:
peek()
elif l == 4:
display()
elif l ==5 :
break
else:
print ("choose in 1-5")
Output of the Program:
1. Add Record
2. Delete Record
3. Search Record
4. Show All Record
5. Exit
Enter your choice: 1
Enter flight no. : 101
Enter flight name: AirIndia
Enter flight fare: 5000
Enter your choice: 1
Enter flight no. : 102
Enter flight name: Indigo
Enter flight fare: 3500
Enter your choice: 4
(101, 'AirIndia', 5000)
(102, 'Indigo', 3500)
Enter your choice: 3
record on top (102, 'Indigo', 3500)
Enter your choice: 2
Rec deleted (102, 'Indigo', 3500)
Enter your choice: 4
(101, 'AirIndia', 5000)
Enter your choice: 5
Program 2
Program:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 27 18:20:42 2025
@author: you
"""
library=[]
def push():
b1=int(input("Enter Book ID : "))
b2=input("Enter Book Title: ")
b3=input("Enter Book Author: ")
s=(b1,b2,b3)
[Link](s)
def pop():
if library==[]:
print("Stack underflow")
else:
x=[Link]()
print("Record deleted",x)
def peek():
if library==[]:
print("Stack underflow")
else:
x=library[-1]
print("Record on top",x)
def display():
if library==[]:
print("Stack underflow")
else:
top=len(library)-1
for i in range(top,-1,-1):
print(library[i])
def clrstack():
if library==[]:
print("Stack already empty")
else:
while library != []:
x=[Link]()
print("Deleted",x)
print("All records cleared")
print("1. Add Book Record")
print("2. Delete Book Record")
print("3. Show Top Book")
print("4. Show All Records")
print("5. Exit")
print("6. Clear Entire Stack")
while True:
l=int(input("Enter your choice: "))
if l==1:
push()
elif l==2:
pop()
elif l==3:
peek()
elif l==4:
display()
elif l==5:
break
elif l==6:
clrstack()
else:
print("Choose in 1-6")
Output of the Program:
1. Add Book Record
2. Delete Book Record
3. Show Top Book
4. Show All Records
5. Exit
6. Clear Entire Stack
Enter your choice: 1
Enter Book ID : 201
Enter Book Title: Python101
Enter Book Author: John
Enter your choice: 1
Enter Book ID : 202
Enter Book Title: DataStructures
Enter Book Author: Alice
Enter your choice: 4
(201, 'Python101', 'John')
(202, 'DataStructures', 'Alice')
Enter your choice: 3
Record on top (202, 'DataStructures', 'Alice')
Enter your choice: 2
Record deleted (202, 'DataStructures', 'Alice')
Enter your choice: 6
Deleted (201, 'Python101', 'John')
All records cleared
Enter your choice: 5