Professional Documents
Culture Documents
Tanmay 2
Tanmay 2
This project consist of the original work done by me under the able
guidance and supervision of my Computer teacher, Geetanjali Hota
Ma’am.
Date:-
Signature of Signature of
Internal Examiner External Examiner
Signature of Supervisor
ACKNOWLEDGEMENT
Date:-
f=open("bookshop.dat","wb")
for i in l1:
pickle.dump(i,f)
f.close()
def display():
f=open("bookshop.dat","rb")
try:
while True:
s=pickle.load(f)
print(s)
except EOFError:
f.close()
def add():
f=open("bookshop.dat","ab")
d={}
d["Name"]=name
d["Author"]=author
d["Price"]=price
d["Stock"]=stock
l1.append(d)
pickle.dump(d,f)
print("Added succesfully")
f.close()
def order():
f=open("bookshop.dat","rb+")
d1={}
for i in l1:
if i["Name"]==a:
d1["Name of recipent:"]=n
d1["Book ordered:"]=a
p=i["Price"]
d1["Price"]=p
t=p*q
d1["Total Bill:"]=t
print("Your invoice:",d1)
i["Stock"]-=q
try:
while True:
rpos=f.tell()
s=pickle.load(f)
if type(s)==dict:
b=s["Name"]
if b==a:
s["Stock"]-=q
f.seek(rpos)
pickle.dump(s,f)
else:
continue
except EOFError:
f.close()
def delete():
f=open("bookshop.dat","wb")
for i in l1:
if i["Name"]==a:
l1.remove(i)
for j in l1:
pickle.dump(j,f)
print("Deleted Successfully")
def search():
f=open("bookshop.dat","rb")
try:
while True:
s=pickle.load(f)
if type(s)==dict:
if s["Name"]==u:
print(s)
found=True
except EOFError:
if found==False:
f.close()
while True:
print("*"*70)
print("1.Display")
print("2.Add")
print("3.Order")
print("4.Delete")
print("5.Search")
print("6.Exit")
if choice==1:
display()
elif choice==2:
add()
elif choice==3:
order()
elif choice==4:
delete()
elif choice==5:
search()
else:
break
OUTPUT
W̲e̲ l̲ c̲ o̲m̲e̲ ̲t̲o̲ t̲ ̲ h̲e̲ ̲S̲A̲S̲ B
̲ ̲ O̲O̲K̲S̲T̲O̲R̲E
*********************************************************************
*
1.Display
2.Add
3.Order
4.Delete
5.Search
6.Exit
{'Name': 'Mahabharata Quest', 'Author': 'Christopher Doyle', 'Price': 550, 'Stock': 18}
{'Name': 'Strange Case of Dr Jekyll and Mr Hyde', 'Auhtor': 'Robert Louis Stevenson',
'Price': 300, 'Stock': 19}
{'Name': 'Khullam Khulla', 'Author': 'Rishi Kapoor', 'Price': 521, 'Stock': 15}
{'Name': 'The English Teacher', 'Author': 'RK Narayan', 'Price': 130, 'Stock': 30}
{'Name': 'The Secret', 'Author': 'Rhonda Byrne', 'Price': 210, 'Stock': 21}
{'Name': 'The Shadow Lines', 'Author': 'Amitav Ghosh', 'Price': 140, 'Stock': 17}
*********************************************************************
*
1.Display
2.Add
3.Order
4.Delete
5.Search
6.Exit
Added succesfully
*********************************************************************
*
1.Display
2.Add
3.Order
4.Delete
5.Search
6.Exit
{'Name': 'Mahabharata Quest', 'Author': 'Christopher Doyle', 'Price': 550, 'Stock': 18}
{'Name': 'Strange Case of Dr Jekyll and Mr Hyde', 'Auhtor': 'Robert Louis Stevenson',
'Price': 300, 'Stock': 19}
{'Name': 'Khullam Khulla', 'Author': 'Rishi Kapoor', 'Price': 521, 'Stock': 15}
{'Name': 'The English Teacher', 'Author': 'RK Narayan', 'Price': 130, 'Stock': 30}
{'Name': 'The Secret', 'Author': 'Rhonda Byrne', 'Price': 210, 'Stock': 21}
{'Name': 'The Shadow Lines', 'Author': 'Amitav Ghosh', 'Price': 140, 'Stock': 17}
{'Name': 'naruto shippuden', 'Author': 'Mamashi Kishimoto', 'Price': 175, 'Stock': 130}
*********************************************************************
*
1.Display
2.Add
3.Order
4.Delete
5.Search
6.Exit
Your invoice: {'Name of recipent:': 'SD', 'Book ordered:': 'The Shadow Lines', 'Price':
140, 'Total Bill:': 420}
*********************************************************************
*
1.Display
2.Add
3.Order
4.Delete
5.Search
6.Exit
{'Name': 'Mahabharata Quest', 'Author': 'Christopher Doyle', 'Price': 550, 'Stock': 18}
{'Name': 'Strange Case of Dr Jekyll and Mr Hyde', 'Auhtor': 'Robert Louis Stevenson',
'Price': 300, 'Stock': 19}
{'Name': 'Khullam Khulla', 'Author': 'Rishi Kapoor', 'Price': 521, 'Stock': 15}
{'Name': 'The English Teacher', 'Author': 'RK Narayan', 'Price': 130, 'Stock': 30}
{'Name': 'The Secret', 'Author': 'Rhonda Byrne', 'Price': 210, 'Stock': 21}
{'Name': 'The Shadow Lines', 'Author': 'Amitav Ghosh', 'Price': 140, 'Stock': 14}
{'Name': 'naruto shippuden', 'Author': 'Mamashi Kishimoto', 'Price': 175, 'Stock': 130}
*********************************************************************
*
1.Display
2.Add
3.Order
4.Delete
5.Search
6.Exit
Deleted Successfully
*********************************************************************
*
1.Display
2.Add
3.Order
4.Delete
5.Search
6.Exit
{'Name': 'Mahabharata Quest', 'Author': 'Christopher Doyle', 'Price': 550, 'Stock': 18}
{'Name': 'Strange Case of Dr Jekyll and Mr Hyde', 'Auhtor': 'Robert Louis Stevenson',
'Price': 300, 'Stock': 19}
{'Name': 'Khullam Khulla', 'Author': 'Rishi Kapoor', 'Price': 521, 'Stock': 15}
{'Name': 'The English Teacher', 'Author': 'RK Narayan', 'Price': 130, 'Stock': 30}
{'Name': 'The Shadow Lines', 'Author': 'Amitav Ghosh', 'Price': 140, 'Stock': 14}
{'Name': 'naruto shippuden', 'Author': 'Mamashi Kishimoto', 'Price': 175, 'Stock': 130}
*********************************************************************
*
1.Display
2.Add
3.Order
4.Delete
5.Search
6.Exit
{'Name': 'naruto shippuden', 'Author': 'Mamashi Kishimoto', 'Price': 175, 'Stock': 130}
*********************************************************************
*
1.Display
2.Add
3.Order
4.Delete
5.Search
6.Exit
1. www.google.com
2. Computer Science with Python by Sumita
Arora
3. www.geeksforgeeks.org