#2 Library Management Software

 Library Management Software using Python

This is the basic python classes and objects project which is used to manage library data .
In this software you can declare a library and books present in it and it offers you following options
  1. You can see all the books available for rent.
  2. You can update the library with new books,remove the books
  3. This software can tell you which student has issued which books from library
  4. This will inform you if the book you want to let is not in library. 
  5. If you want to know which person has taken a particular book then you have simply to enter the name of book and this programme will simply tell you name of person.
Code for the programme

*********************************************

class library:
def __init__(self,list_of_books,library_name):

self.list_of_books = list_of_books
self.name_of_library = library_name
self.book_lender = {}

def display_book(self):
"""Function for displaying books"""
print( f"The name of the books available in library {self.name_of_library} are ")
for books in self.list_of_books:
print(books)

def lend_books(self):
"""Function for lending books"""
user_name = input("Please Enter your name = ")
book_name = input("Enter the book name of book you want to lend = ")
if book_name not in self.book_lender.keys():
self.book_lender.update({book_name:user_name})
print("your information has been updated")
else:
print(f"sorry!....\n Dear {user_name} The {book_name} Book is already taken by {self.book_lender[book_name]} ")


def add_book(self):
"""Function for adding books in the library"""
b = input("Enter the name of book you want to add = ")
self.list_of_books.append(b)
print("your information has been updated")
def return_book(self):
"""Function for returning the books"""
c = input("Enter the name of book you have to return = ")
self.book_lender.pop(c)
print("your information has been updated")

# object of library
ashihs_library = library(['physics','maths','chemistry','english','punjabi','computer','EVS'],'ashish library')

while True:
print(f"Welcome to online library managment system and now you are in {ashihs_library.name_of_library} ")
print("Please choose one of the following ")

print("1.) See the books available")
print("2,) To take any book on rent")
print("3.) To add the book in library")
print("4.) For returning a book")

m = int(input("Enter your answer = "))
if m == 1:
ashihs_library.display_book()
elif m == 2:
ashihs_library.lend_books()
elif m == 3:
ashihs_library.add_book()
elif m == 4:
ashihs_library.return_book()
else:
print("your input is wrong ! please try again")

z = input("Press q to quit and press c to continue = ")
if z=='q':
print("Thanks for using the system")
break
elif z=='c':
continue
else:
print("your input is wrong")


*********************************************

Comments

Popular posts from this blog

#3 Water remainder Programme