Library Management system python code
Library Management system python code
{'id':10001,'name':'Meluha','author':'Amish Tripathi','genre':'Indian
mythology','price':'250'},
{'id':10002,'name':'Nagas','author':'Amish Tripathi','genre':'Indian
mythology','price':'250'},
{'id':10003,'name':'Vayuputras','author':'Amish Tripathi','genre':'Indian
mythology','price':'350'},
{'id':10004,'name':'Ram','author':'Amish Tripathi','genre':'Indian
mythology','price':'250'},
{'id':10005,'name':'Sita','author':'Amish Tripathi','genre':'Indian
mythology','price':'250'},
{'id':10006,'name':'Ravan','author':'Amish Tripathi','genre':'Indian
mythology','price':'350'},
{'id':10007,'name':'The war of lanka','author':'Amish Tripathi','genre':'Indian
mythology','price':'350'},
{'id':10008,'name':'The hidden hindu- Part 1','author':'Akshat
Gupta','genre':'Indian mythology','price':'350'},
{'id':10009,'name':'The hidden hindu- Part 2','author':'Akshat
Gupta','genre':'Indian mythology','price':'350'},
{'id':10010,'name':'The hidden hindu- Part 3','author':'Akshat
Gupta','genre':'Indian mythology','price':'350'},
{'id':10011,'name':"The serpent's revenge",'author':'Sudha
Murty','genre':'Indian mythology','price':'200'},
{'id':10012,'name':'The man from the egg','author':'Sudha
Murty','genre':'Indian mythology','price':'200'},
{'id':10013,'name':'The upside down king','author':'Sudha
Murty','genre':'Indian mythology','price':'200'},
{'id':10014,'name':'The daughter from the wishing tree','author':'Sudha
Murty','genre':'Indian mythology','price':'200'},
{'id':10015,'name':'The sage with two horns','author':'Sudha
Murty','genre':'Indian mythology','price':'200'}
]
name=input('Hello here! Welcome to Vish Library. May i know your name? ')
print('Hello',name,'!','Please choose from the menu given below.')
while True:
print("""\n\nChoose from the following menu:
1. Veiw all the books in the library
2. Add new book
3. Search books by a particular author
4. Display all books with price less than 300
5. Exit""")
c=int(input("Enter your choice (1/2/3/4/5): "))
if c==1:
for i in range(0,len(list)):
print("\nId - ",list[i]['id'],", Name - ",list[i]['name'],", Author -
",list[i]['author'],", Genre - ",list[i]['genre'],", Price - ",list[i]['price'])
if c==2:
id=input("Enter the ID of the book: ")
name=input("Enter the name of the book: ")
author=input("Enter the Author of the book: ")
genre=input("Enter the genre of the book: ")
price=input("Enter the price of the book: ")
d={'id':id,'name':name,'author':author,'genre':genre,'price':price}
list.append(d)
for j in range(0,len(list)):
print("\nId - ",list[j]['id'],", Name - ",list[j]['name'],", Author -
",list[j]['author'],", Genre - ",list[j]['genre'],", Price - ",list[j]['price'])
if c==3:
fauthor=input("Enter the author whose book you need to find: ")
for a in range(len(list)):
if list[a]['author']==fauthor:
print("\nId - ",list[a]['id'],", Name - ",list[a]['name'],", Author
- ",list[a]['author'],", Genre - ",list[a]['genre'],", Price - ",list[a]['price'])
if c==4:
for b in range(len(list)):
if list[b]['price']<='300':
print("\nId - ",list[b]['id'],", Name - ",list[b]['name'],", Author
- ",list[b]['author'],", Genre - ",list[b]['genre'],", Price - ",list[b]['price'])
if c==5:
break