Simple Library Management System in Python With Source Code

library management system project in python, library management system project pdf class 12 python, library management system project with coding, simple library management system in python with source code

simple library management system in python with source code

 

The Simple Library Management System in Python with source code is a python project than can borrow and return a book in a library. this system is a working simple function that enables one to borrow a book and return a book. the Simple Library Management System in Python is user and mobile-friendly and you can easily modify and use this system.

About Simple Library Management System in Python

The Simple Library System was created in a console application, the user can access the system without login information provided. The user will be able to do many things in the library like borrowing books, displaying available books, and returning borrowed books. This library will make things easier for your students by allowing them to quickly borrow a book at any time due to its speed of transaction processing.

The system allows you to save all transactions that occur above as a series of strings within the template file itself. If you want each transaction stored permanently then simply insert some storing functions within the code used to execute the different transactions so they can be saved into one dedicated database only open during business hours during which students use this system most frequently.

Simple Library System using Python  Features:

  • List all the books
  • Request a book
  • Return a book

Simple Library System using Python Source code:-

 

class Library:
    def __init__(self, listOfBooks):
        self.books = listOfBooks

    def displayAvailableBooks(self):
        print("Books present in this library are: ")
        for book in self.books: 
            print(" *" + book)
    
    def borrowBook(self, bookName):
        if bookName in self.books:
            print(f"You have been issued {bookName}. Please keep it safe and return it within 30 days")
            self.books.remove(bookName)
            return True
        else:
            print("Sorry, This book is either not available or has already been issued to someone else. Please wait until the book is available")
            return False

    def returnBook(self, bookName):
        self.books.append(bookName)
        print("Thanks for returning this book! Hope you enjoyed reading it. Have a great day!")

class Student: 
    def requestBook(self):
        self.book = input("Enter the name of the book you want to borrow: ")
        return self.book

    def returnBook(self):
        self.book = input("Enter the name of the book you want to return: ")
        return self.book
         

if __name__ == "__main__":
    centraLibrary = Library(["JavaScript", "PHP", "C++", "Python", "Java"])
    student = Student()
    
    while(True):
        welcomeMsg = '''\n====== Welcome to Simple Library  System======
        Please choose an option:
        1. List all the books
        2. Request a book
        3. Return a book
        4. Exit the Library
        '''
        print(welcomeMsg)
        a = int(input("Enter a choice: "))
        if a == 1:
            centraLibrary.displayAvailableBooks()
        elif a == 2:
            centraLibrary.borrowBook(student.requestBook())
        elif a == 3:
            centraLibrary.returnBook(student.returnBook())
        elif a == 4:
            print("Thanks for choosing our Library.")
            exit()
        else:
            print("Invalid Choice!")

        

How to run this project?

  • Copy the source code in this site.
  • Open you code editor
  • Paste this code.
  • save this file using extention .py .
  • Run the py file to launch the program

Leave a Comment

Verified by MonsterInsights