You are on page 1of 10

PGM.

NO: 18 DICTIONARY OPERATIONS - I


(RETAIL PRODUCT CATALOG)
DATE:

AIM:

To write a Python program to perform the dictionary operation for Retail


Product Catalog to append, update, delete and display all the products.

SOURCE CODE:

prod=dict()
n=int(input("Enter the no. of products: "))

i=1
while i<=n:
pname=input("Enter the product name: ")
pri=float(input("Enter the Price: "))
prod[pname]=pri
i=i+1

ch=0
while ch!=5:
print("1.Append \n2.Update \n3.Delete \n4.Display all \n5.Exit")
ch=int(input("Enter Ur Choice: "))

if(ch==1):
pname=input("Enter the new product name: ")
pri=float(input("Enter the Price: "))
prod[pname]=pri
print("\n\t Product Appended Successfully!!!")

elif(ch==2):
upn=input("Enter the product name to be updated: ")
if upn in prod:
npr=float(input("Enter the New Price: "))
prod[pname]=npr
print("\n\t Product Price Updated Successfully!!!")
else:
print("Product doesn't Exist")

elif(ch==3):
upn=input("Enter the product name to be deleted: ")
if upn in prod:
print(upn, end=" ")
print(prod.pop(upn),end=" ")
print("\t Product Info Deleted !!!")
else:
print("Product doesn't Exist")

elif(ch==4):
print("\nProduct Name \t Price")
for i in prod:
print(i,"\t",prod[i])

elif(ch==5):
print("Thank You:)")

else:
print("Enter the choice bw 1 and 4")

INPUT/OUTPUT:

Enter the no. of products: 3

Enter the product name: Colgate

Enter the Price: 20.75

Enter the product name: Pepsodent

Enter the Price: 17.75

Enter the product name: Sensodyne

Enter the Price: 35

1.Append

2.Update

3.Delete

4.Display all

5.Exit
Enter Ur Choice: 1

Enter the new product name: Close Up

Enter the Price: 25.50

Product Appended Successfully!!!

Enter Ur Choice: 2

Enter the product name to be updated: Colgate

Enter the New Price: 22

Product Price Updated Successfully!!!

Enter Ur Choice: 4

Product Name Price

Colgate 20.75

Pepsodent 17.75

Sensodyne 35.0

Close Up 22.0

Enter Ur Choice: 3

Enter the product name to be deleted: Sensodyne

Sensodyne 35.0 Product Info Deleted!!!

Enter Ur Choice: 5

Thank You :)

RESULT:
Thus the program is executed successfully.
PGM.NO: 19 DICTIONARY OPERATIONS - II
(STUDENT DETAIL SYSTEM)
DATE:

AIM:

To write a Python program to perform the dictionary operations for student


detail system to add, search, pop, display and clear all students.

SOURCE CODE:

stu=dict()
ch=0

while ch!=6:
print("\n\n\t\t ********* Student Detail System *********")
print("1. Add new \n2. Search \n3. Pop \n4. Display
\n5. Clear all \n6. Exit")
ch=int(input("Enter Ur Choice: "))

if(ch==1):
stid=int(input("Enter the Student ID: "))
n=input("Enter the Student name: ")
m=float(input("Enter the Average marks: "))
g=input("Enter the Grade: ")
stu[stid]=(n,m,g)

elif(ch==2):
sid=int(input("Enter the Student ID for searching: "))
if sid in stu:
print(" Name , Marks , Grade ")
print(stu.get(sid))
else:
print("Student not in the list")
elif(ch==3):
sid=int(input("Enter the Student ID for deleting: "))
if sid in stu:
del stu[sid]
print("Record deleted !!!!")
else:
print("Student not in the list")
elif(ch==4):
for i in stu:
print(i,end="\t")
t=stu[i]
for j in t:
print(j,end="\t")
print()
print("\n Total Students : ",len(stu))

elif(ch==5):
stu.clear()
print("All the records deleted !!!")

elif(ch==6):
print("\n \t Thank You!!! Visit Again!!")

else:
print("Enter the valid choice between 1 and 6")

INPUT/OUTPUT:

********* Student Detail System *********


1. Add new
2. Search
3. Pop
4. Display
5. Clear all
6. Exit

Enter Ur Choice: 1
Enter the Student ID: 1
Enter the Student name: Ajay
Enter the Average marks: 99
Enter the Grade: A

Enter Ur Choice: 1
Enter the Student ID: 5
Enter the Student name: Hari
Enter the Average marks: 89
Enter the Grade: B

Enter Ur Choice: 1
Enter the Student ID: 10
Enter the Student name: Vishnu
Enter the Average marks: 93
Enter the Grade: A

Enter Ur Choice: 4
1 Ajay 99.0 A
5 Hari 89.0 B
10 Vishnu 93.0 A

Total Students : 3

Enter Ur Choice: 2
Enter the Student ID for searching: 5
Name , Marks , Grade
('Hari', 89.0, 'B')

Enter Ur Choice: 3
Enter the Student ID for deleting: 10
Record deleted !!!!

Enter Ur Choice: 4
1 Ajay 99.0 A
5 Hari 89.0 B

Total Students : 2

Enter Ur Choice: 5
All the records deleted!!!

Enter Ur Choice: 6
Thank You!!! Visit Again!!

RESULT:
Thus the program is executed successfully.
SSM SCHOOL PROGRAM MANUAL

PGM.NO: 20 DICTIONARY OPERATIONS - III


(LIBRARY MANAGEMENT SYSTEM)
DATE:

AIM:

To write a Python program to perform the dictionary operations for library


management system to add, search, pop, check total books and clear all books.

SOURCE CODE:

book=dict()
ch=0

while ch!=6:
print("\n\n\t\t ********* Library Management System *********")
print("1. Add new \n2. Search \n3. Pop \n4. Check Total books
\n5. Clear all \n6. Exit")
ch=int(input("Enter Ur Choice: "))

if(ch==1):
bid=int(input("Enter the ISBN: "))
n=input("Enter the book name: ")
p=float(input("Enter the price: "))
y=int(input("Enter the Publication Year: "))
book[bid]=(n,p,y)

elif(ch==2):
bk=int(input("Enter the ISBN for searching: "))
if bk in book:
print(" Name, Price, Year ")
print(book.get(bk))
else:
print("ISBN not available")
elif(ch==3):
bk=int(input("Enter the ISBN for deleting: "))
if bk in book:
del book[bk]
print("Record deleted !!!!")
else:
print("ISBN not available")
elif(ch==4):
for i in book:
print(i,end="\t")
t=book[i]
for j in t:
print(j,end="\t")
print()
print("\n Total books : ",len(book))

elif(ch==5):
book.clear()
print("All the records deleted !!!")

elif(ch==6):
print("\n \t Thank You!!! Visit Again!!")

else:
print("Enter the valid choice between 1 and 6")

INPUT/OUTPUT:

********* Library Management System *********


1. Add new
2. Search
3. Pop
4. Check Total books
5. Clear all
6. Exit

Enter Ur Choice: 1
Enter the ISBN: 1001
Enter the book name: Operating System
Enter the price: 350
Enter the Publication Year: 2009

Enter Ur Choice: 1
Enter the ISBN: 1002
Enter the book name: Data structure
Enter the price: 420
Enter the Publication Year: 2007
Enter Ur Choice: 1
Enter the ISBN: 1003
Enter the book name: System Analysis and Design
Enter the price: 520
Enter the Publication Year: 2008

Enter Ur Choice: 2
Enter the ISBN for searching: 1002
Name, Price, Year
('Data structure', 420.0, 2007)

Enter Ur Choice: 4
1001 Operating System 350.0 2009
1002 Data structure 420.0 2007
1003 System Analysis and Design 520.0 2008
Total books: 3

Enter Ur Choice: 3
Enter the ISBN for deleting: 1003
Record deleted!!!

Enter Ur Choice: 5
All the records deleted!!!

Enter Ur Choice: 6
Thank You!!! Visit Again!!

RESULT:
Thus the program is executed successfully

You might also like