Set - 3
Set - 3
Name:
Date:
Class: 12
Section:
SET – 03
Practical - 1:
Write a menu driven program which insert, delete and display the details of a book such as
Book=[]
c='y'
while(c=='y' or c=='Y'):
1 SET - 3
print("1: Add Book Details: ")
if(choice==1):
B=(book_id,book_name,price)
Book.append(B)
elif(choice==2):
if(Book==[]):
print("Stack Empty")
else:
2 SET - 3
print("Deleted element is: ",Book.pop())
#pop() method is used to delete the topmost element from the stack
elif(choice==3):
L=len(Book)
while(L>0):
print(Book [L-1])
L=L-1
else:
print("Wrong/Invalid Choice")
Output:
1: Add Book Details:
3 SET - 3
Enter Book Id: 101
4 SET - 3
Enter Book Name: Maths by R D SHARMA
5 SET - 3
1: Add Book Details:
Practical - 2:
(a) Display the average sale of all categories
6 SET - 3