This commit is contained in:
RafayAhmad7548 2024-09-09 16:59:28 +05:00
parent 2992f4f408
commit 4f46de8d00
3330 changed files with 394553 additions and 76939 deletions

View file

@ -0,0 +1,21 @@
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
for key in book.keys():
print(key, ':', book.get(key))
found = True
break
if not found:
print('book title not function')

View file

@ -0,0 +1,17 @@
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
for key in book.keys():
print(key, ' : ', book.get(key))
break

View file

@ -0,0 +1,51 @@
def getdict(books: list, title: str) -> dict:
for book in books:
book = dict(book)
if book.get('title') == title:
return book
return None
def inventory_worth():
worth = 0
for book in bookstore:
book = dict(book)
worth += book.get('price')*book.get('quantity')
return worth
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
book = getdict(bookstore, search_title)
if book is None:
print('book title not function')
else:
for key in book.keys():
print(key, ':', book.get(key))
update_title = input('enter a title to update a book: ')
book = getdict(bookstore, update_title)
if book is None:
print('book title not function')
else:
new_author = input('enter updated author')
new_quantity = input('enter updated quantity')
new_price = input('enter updated price')
book['author'] = new_author
book['quantity'] = new_quantity
book['price'] = new_price

View file

@ -0,0 +1,44 @@
def getdict(books: list, title: str) -> dict:
for book in books:
book = dict(book)
if book.get('title') == title:
return book
return None
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
book = getdict(bookstore, search_title)
if book is None:
print('book title not function')
else:
for key in book.keys():
print(key, ':', book.get(key))
update_title = input('enter a title to update a book: ')
book = getdict(bookstore, update_title)
if book is None:
print('book title not function')
else:
new_author = input('enter updated author')
new_quantity = input('enter updated quantity')
new_price = input('enter updated price')
book['author'] = new_author
book['quantity'] = new_quantity
book['price'] = new_price

View file

@ -0,0 +1,16 @@
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title for book ', i, ': ')
author = input('enter book author for book ', i, ': ')
quantity = input('enter book quantity for book ', i, ': ')
price = input('enter book price for book ', i, ': ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
for details in book:
print(details)

View file

@ -0,0 +1,16 @@
bookstore = []
num = input('how many books would you like to add: ')
for i in range(num):
title = input('enter book title for book ', i, ': ')
author = input('enter book author for book ', i, ': ')
quantity = input('enter book quantity for book ', i, ': ')
price = input('enter book price for book ', i, ': ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
for details in book:
print(details)

View file

@ -0,0 +1,51 @@
def getdict(books: list, title: str) -> dict:
for book in books:
book = dict(book)
if book.get('title') == title:
return book
return None
def inventory_worth():
worth = 0
for book in bookstore:
book = dict(book)
worth += int(book.get('price'))*int(book.get('quantity'))
return worth
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
book = getdict(bookstore, search_title)
if book is None:
print('book title not function')
else:
for key in book.keys():
print(key, ':', book.get(key))
update_title = input('enter a title to update a book: ')
book = getdict(bookstore, update_title)
if book is None:
print('book title not function')
else:
new_author = input('enter updated author: ')
new_quantity = input('enter updated quantity: ')
new_price = input('enter updated price: ')
book['author'] = new_author
book['quantity'] = new_quantity
book['price'] = new_price
print('you have books worth: ',inventory_worth(), 'rupee')

View file

@ -0,0 +1,16 @@
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
for details in book:
print(details)

View file

@ -0,0 +1,57 @@
def getdict(books: list, title: str) -> dict:
for book in books:
book = dict(book)
if book.get('title') == title:
return book
return None
def inventory_worth():
worth = 0
for book in bookstore:
book = dict(book)
worth += int(book.get('price'))*int(book.get('quantity'))
return worth
def report():
for book in bookstore:
book = dict(book)
for key in book.keys():
print(key, ':', book.get(key))
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
book = getdict(bookstore, search_title)
if book is None:
print('book title not function')
else:
for key in book.keys():
print(key, ':', book.get(key))
update_title = input('enter a title to update a book: ')
book = getdict(bookstore, update_title)
if book is None:
print('book title not function')
else:
new_author = input('enter updated author: ')
new_quantity = input('enter updated quantity: ')
new_price = input('enter updated price: ')
book['author'] = new_author
book['quantity'] = new_quantity
book['price'] = new_price
print('you have books worth: ',inventory_worth(), 'rupee')
report()

View file

@ -0,0 +1,8 @@
bookstore = []
num = input('how many books would you like to add: ')
for i in range(num):
title = input('enter book title for book ', i, ': ')
author = input('enter book author for book ', i, ': ')
quantity = input('enter book quantity for book ', i, ': ')
price = input('enter book price for book ', i, ': ')

View file

@ -0,0 +1,24 @@
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
for key in book.keys():
print(key, ':', book.get(key))
found = True
break
if not found:
print('book title not function')
update_title = input('enter a title to update a book: ')

View file

@ -0,0 +1,13 @@
bookstore = []
num = input('how many books would you like to add: ')
for i in range(num):
title = input('enter book title for book ', i, ': ')
author = input('enter book author for book ', i, ': ')
quantity = input('enter book quantity for book ', i, ': ')
price = input('enter book price for book ', i, ': ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
for book in bookstore:

View file

@ -0,0 +1,33 @@
def getdict(books: list, title: str) -> dict:
for book in books:
book = dict(book)
if book.get('title') == title:
return book
return None
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
book = getdict(bookstore, search_title)
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
for key in book.keys():
print(key, ':', book.get(key))
found = True
break
if not found:
print('book title not function')
update_title = input('enter a title to update a book: ')

View file

@ -0,0 +1,17 @@
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
for key in book.keys():
print(key, ':', book.get(key))
break

View file

@ -0,0 +1,11 @@
bookstore = []
num = input('how many books would you like to add: ')
for i in range(num):
title = input('enter book title for book ', i, ': ')
author = input('enter book author for book ', i, ': ')
quantity = input('enter book quantity for book ', i, ': ')
price = input('enter book price for book ', i, ': ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')

View file

@ -0,0 +1,15 @@
bookstore = []
num = input('how many books would you like to add: ')
for i in range(num):
title = input('enter book title for book ', i, ': ')
author = input('enter book author for book ', i, ': ')
quantity = input('enter book quantity for book ', i, ': ')
price = input('enter book price for book ', i, ': ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:

View file

@ -0,0 +1,32 @@
def getdict(books: list) -> dict:
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
found = True
break
if not found:
return None
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
for key in book.keys():
print(key, ':', book.get(key))
found = True
break
if not found:
print('book title not function')
update_title = input('enter a title to update a book: ')

View file

@ -0,0 +1,16 @@
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
print(book.keys())
print(book.values())

View file

@ -0,0 +1,31 @@
def getdict(books: list) -> dict:
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
return book
return None
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
for key in book.keys():
print(key, ':', book.get(key))
found = True
break
if not found:
print('book title not function')
update_title = input('enter a title to update a book: ')

View file

@ -0,0 +1,20 @@
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
for key in book.keys():
print(key, ':', book.get(key))
found = True
break
if not found:
print('book title not function')

View file

@ -0,0 +1,11 @@
bookstore = []
num = input('how many books would you like to add: ')
for i in range(num):
title = input('enter book title for book ', i, ': ')
author = input('enter book author for book ', i, ': ')
quantity = input('enter book quantity for book ', i, ': ')
price = input('enter book price for book ', i, ': ')
bookstore.append({title : [author, quantity, price]})
search_title = input('enter a title to search for a book: ')

View file

@ -0,0 +1,21 @@
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
for key in book.keys():
print(key, ':', book.get(key))
found = True
break
if not found:
print('book title not function')

View file

@ -0,0 +1 @@
{"version":1,"resource":"file:///home/rafayahmad/Stuff/Coding/Python/IDS/lab3/task2.py","entries":[{"id":"wDhU.py","timestamp":1725421605403},{"id":"i9F0.py","timestamp":1725421711590},{"id":"hFQE.py","timestamp":1725421730677},{"id":"E8n4.py","timestamp":1725421773879},{"id":"mEnz.py","timestamp":1725421811156},{"id":"aQUp.py","timestamp":1725421883378},{"id":"LAqI.py","timestamp":1725421945135},{"id":"GRA5.py","timestamp":1725421985676},{"id":"sGVN.py","timestamp":1725422118608},{"id":"fRsZ.py","timestamp":1725422140831},{"id":"LKfn.py","timestamp":1725422175994},{"id":"8bFS.py","timestamp":1725422192044},{"id":"83bx.py","timestamp":1725422224217},{"id":"B7tF.py","timestamp":1725422279140},{"id":"PTT4.py","timestamp":1725422375516},{"id":"22Cc.py","timestamp":1725422964010},{"id":"L1Yk.py","timestamp":1725423021450},{"id":"UxJx.py","timestamp":1725423101674},{"id":"b41e.py","timestamp":1725423119011},{"id":"1vPS.py","timestamp":1725424246234},{"id":"FTTv.py","timestamp":1725424988091},{"id":"uHcX.py","timestamp":1725425011055},{"id":"NVYV.py","timestamp":1725425115622},{"id":"Svv5.py","timestamp":1725425152336},{"id":"j6D0.py","timestamp":1725425163396},{"id":"kYms.py","timestamp":1725425191563},{"id":"v1gK.py","timestamp":1725425210593},{"id":"Gzt2.py","timestamp":1725425296520},{"id":"o2kN.py","timestamp":1725425331127},{"id":"nBwS.py","timestamp":1725425366241},{"id":"h7w0.py","timestamp":1725425387324},{"id":"jgwj.py","timestamp":1725425490021},{"id":"63Rs.py","timestamp":1725425537708},{"id":"297x.py","timestamp":1725425687599},{"id":"kZ4o.py","timestamp":1725425737616},{"id":"o62K.py","timestamp":1725425761340},{"id":"8w7p.py","timestamp":1725425841120},{"id":"CHEj.py","timestamp":1725426141499},{"id":"jBhL.py","timestamp":1725426273047}]}

View file

@ -0,0 +1,14 @@
bookstore = []
num = input('how many books would you like to add: ')
for i in range(num):
title = input('enter book title for book ', i, ': ')
author = input('enter book author for book ', i, ': ')
quantity = input('enter book quantity for book ', i, ': ')
price = input('enter book price for book ', i, ': ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:

View file

@ -0,0 +1,29 @@
def getdict(books: list, title: str) -> dict:
for book in books:
book = dict(book)
if book.get('title') == title:
return book
return None
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
book = getdict(bookstore, search_title)
if book is None:
print('book title not function')
else:
for key in book.keys():
print(key, ':', book.get(key))
update_title = input('enter a title to update a book: ')

View file

@ -0,0 +1,7 @@
bookstore = []
num = input('how many books would you like to add: ')
for i in range(num):
title = input('enter book title for book ', i, ': ')
author = input('enter book author for book ', i, ': ')
title = input('enter book title for book ', i, ': ')

View file

@ -0,0 +1,5 @@
bookstore = []
num = input('how many books would you like to add: ')
for i in range(num):
title = input('enter book title for book ', i, ': ')

View file

@ -0,0 +1,31 @@
def getdict(books: list) -> dict:
for book in books:
book = dict(book)
if book.get('title') == search_title:
return book
return None
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
for key in book.keys():
print(key, ':', book.get(key))
found = True
break
if not found:
print('book title not function')
update_title = input('enter a title to update a book: ')

View file

@ -0,0 +1,59 @@
def getdict(books: list, title: str) -> dict:
for book in books:
book = dict(book)
if book.get('title') == title:
return book
return None
def inventory_worth():
worth = 0
for book in bookstore:
book = dict(book)
worth += int(book.get('price'))*int(book.get('quantity'))
return worth
def report():
for book in bookstore:
book = dict(book)
for key in book.keys():
print(key, ':', book.get(key))
if book.get('quantity') == '0':
print('boooook ouuut off stooooooock!!!!!!!!!!!!!!!!!!')
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
book = getdict(bookstore, search_title)
if book is None:
print('book title not function')
else:
for key in book.keys():
print(key, ':', book.get(key))
update_title = input('enter a title to update a book: ')
book = getdict(bookstore, update_title)
if book is None:
print('book title not function')
else:
new_author = input('enter updated author: ')
new_quantity = input('enter updated quantity: ')
new_price = input('enter updated price: ')
book['author'] = new_author
book['quantity'] = new_quantity
book['price'] = new_price
print('you have books worth: ',inventory_worth(), 'rupee')
report()

View file

@ -0,0 +1,36 @@
def getdict(books: list, title: str) -> dict:
for book in books:
book = dict(book)
if book.get('title') == title:
return book
return None
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
book = getdict(bookstore, search_title)
if book is None:
print('book title not function')
else:
for key in book.keys():
print(key, ':', book.get(key))
update_title = input('enter a title to update a book: ')
book = getdict(bookstore, update_title)
if book is None:
print('book title not function')
else:
new_author = input('enter updated author')
new_quantity = input('enter updated quantity')
new_price = input('enter updated price')

View file

@ -0,0 +1,32 @@
def getdict(books: list) -> dict:
for book in books:
book = dict(book)
if book.get('title') == search_title:
return book
return None
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
book = getdict(bookstore)
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
for key in book.keys():
print(key, ':', book.get(key))
found = True
break
if not found:
print('book title not function')
update_title = input('enter a title to update a book: ')

View file

@ -0,0 +1,51 @@
def getdict(books: list, title: str) -> dict:
for book in books:
book = dict(book)
if book.get('title') == title:
return book
return None
def inventory_worth():
worth = 0
for book in bookstore:
book = dict(book)
worth += book.get('price')*book.get('quantity')
return worth
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
book = getdict(bookstore, search_title)
if book is None:
print('book title not function')
else:
for key in book.keys():
print(key, ':', book.get(key))
update_title = input('enter a title to update a book: ')
book = getdict(bookstore, update_title)
if book is None:
print('book title not function')
else:
new_author = input('enter updated author')
new_quantity = input('enter updated quantity')
new_price = input('enter updated price')
book['author'] = new_author
book['quantity'] = new_quantity
book['price'] = new_price
print(inventory_worth())

View file

@ -0,0 +1,9 @@
bookstore = []
num = input('how many books would you like to add: ')
for i in range(num):
title = input('enter book title for book ', i, ': ')
author = input('enter book author for book ', i, ': ')
quantity = input('enter book quantity for book ', i, ': ')
price = input('enter book price for book ', i, ': ')
bookstore.append({title : [author, quantity, price]})

View file

@ -0,0 +1,28 @@
def getdict(books: list, title: str) -> dict:
for book in books:
book = dict(book)
if book.get('title') == title:
return book
return None
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
book = getdict(bookstore, search_title)
if book is None:
print('book title not function')
for key in book.keys():
print(key, ':', book.get(key))
update_title = input('enter a title to update a book: ')

View file

@ -0,0 +1,26 @@
def getdict(books: list, title: str) -> dict:
for book in books:
book = dict(book)
if book.get('title') == title:
return book
return None
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
book = getdict(bookstore, search_title)
for key in book.keys():
print(key, ':', book.get(key))
print('book title not function')
update_title = input('enter a title to update a book: ')

View file

@ -0,0 +1,51 @@
def getdict(books: list, title: str) -> dict:
for book in books:
book = dict(book)
if book.get('title') == title:
return book
return None
def inventory_worth():
worth = 0
for book in bookstore:
book = dict(book)
worth += book.get('price')*book.get('quantity')
return worth
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
book = getdict(bookstore, search_title)
if book is None:
print('book title not function')
else:
for key in book.keys():
print(key, ':', book.get(key))
update_title = input('enter a title to update a book: ')
book = getdict(bookstore, update_title)
if book is None:
print('book title not function')
else:
new_author = input('enter updated author')
new_quantity = input('enter updated quantity')
new_price = input('enter updated price')
book['author'] = new_author
book['quantity'] = new_quantity
book['price'] = new_price
print('you have books worth: ',inventory_worth(), 'rupee')

View file

@ -0,0 +1,13 @@
bookstore = []
num = input('how many books would you like to add: ')
for i in range(num):
title = input('enter book title for book ', i, ': ')
author = input('enter book author for book ', i, ': ')
quantity = input('enter book quantity for book ', i, ': ')
price = input('enter book price for book ', i, ': ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
for book in bookstore:
if book.get('title') == search_title:

View file

@ -0,0 +1,33 @@
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
for key in book.keys():
print(key, ':', book.get(key))
found = True
break
if not found:
print('book title not function')
update_title = input('enter a title to update a book: ')
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
for key in book.keys():
print(key, ':', book.get(key))
found = True
break
if not found:
print('book title not function')

View file

@ -0,0 +1,33 @@
def getdict(books: list, title: str) -> dict:
for book in books:
book = dict(book)
if book.get('title') == title:
return book
return None
bookstore = []
num = int(input('how many books would you like to add: '))
for i in range(num):
title = input('enter book title: ')
author = input('enter book author: ')
quantity = input('enter book quantity: ')
price = input('enter book price: ')
bookstore.append({"title" : title, "author" : author, "quantity" : quantity, "price" : price})
search_title = input('enter a title to search for a book: ')
book = getdict(bookstore, search_title)
for book in bookstore:
book = dict(book)
if book.get('title') == search_title:
for key in book.keys():
print(key, ':', book.get(key))
found = True
break
if not found:
print('book title not function')
update_title = input('enter a title to update a book: ')

View file

@ -0,0 +1 @@
bookstore = []