Pyexp 1
Pyexp 1
WORKSHEET 1
Aim: Imagine you are developing a library checkout system and you need to create
a function that facilitate the checkout process. Describe the design and
functionality of this function considering parameters such as user detail and book
title. Discuss how would implement the logic to check the availability in library
inventory accordingly and provide the feedback to user regarding in sucess or
failure of checkout. Additionally address any potential error scenarios such as book
being out of stock or user provide invalid information. how would you ensure that
the function is efficient readable and adherer best practices in python function
design. provide insight to how would you handle the concurrent request in multiple
user environment use following terms
(i) user detail & book title
(ii) book author and publication data
(iii) library location and opening hours
2. Source Code:
def inventory():
# book_list={"ranitatt":3, "virsa":1,"punjab":0}
print("books avaliable ")
print(book_list)
def record():
user_info = ["sagan", "ankit", "raman"]
name = input("enter user name: ")
if name in user_info:
inventory()
else:
print("detail mismatched : error USER NOT FOUND ")
i='y'
while i=='y':
record()
print("is their any user in queue: ")
req=input("enter y or n: ")
i=req
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
3. Screenshot of Outputs:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING