SIMPLE LIBRARY SYSTEM USING PYTHON 2023. - SAMALEN TV

SAMALEN TV

Trending on SAMALEN TV App

Notification texts go here Contact Us Buy Now!
Posts

SIMPLE LIBRARY SYSTEM USING PYTHON 2023.

Please wait 0 seconds...
Scroll Down and click on Go to Link for destination
Congrats! Link is Generated

Simple python codes to make a simple library system
This code made by SAMALEN TV


class Book:
def __init__(self, title, author, isbn):
self.title = title
self.author = author
self.isbn = isbn
class Library:
def __init__(self):
self.books = []
def add_book(self, book):
self.books.append(book)
print("Book added successfully!")
    
    def remove_book(self, book):
        if book in self.books:
            self.books.remove(book)
            print("Book removed successfully!")
        else:
            print("Book not found.")
    
    def display_books(self):
        if not self.books:
            print("No books in library.")
        else:
            print("List of books:")
            for book in self.books:
                print(f"{book.title} by {book.author} (ISBN: {book.isbn})")
                
library = Library()

while True:
    print("1. Add book")
    print("2. Remove book")
    print("3. Display books")
    print("4. Quit")
    
    choice = input("Enter your choice: ")
    
    if choice == "1":
        title = input("Enter book title: ")
        author = input("Enter book author: ")
        isbn = input("Enter book ISBN: ")
        book = Book(title, author, isbn)
        library.add_book(book)
    
    elif choice == "2":
        title = input("Enter book title: ")
        author = input("Enter book author: ")
        isbn = input("Enter book ISBN: ")
        book = Book(title, author, isbn)
        library.remove_book(book)
    
    elif choice == "3":
        library.display_books()
    
    elif choice == "4":
        print("Goodbye!")
        break
    
    else:
        print("Invalid choice. Try again.")


Run it to see results and Comment if anything wrong I will help you samalen Tv for you

Getting Info...

Post a Comment

Your message is directed to SAMALEN TV
Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.