top of page

Library Software in Python


 


 

Source code :


# student labarary project class Library: def __init__(self, listOfBooks): self.books = listOfBooks pass def displayAvailableBooks(self): print("\tBooks present in Library are : ") # i=1 for book in self.books: print(f"\t * {book}") # i+=1 def borrowBook(self, bookName): if bookName in self.books: print( f"you have issued {bookName}. \n pls keep this safe and return in 30 days.") self.books.remove(bookName) return True else: print("Sorry this book has already been issued to someone else. Pls wait until he/she return the book .") return False def returnBook(self, bookName): self.books.append(bookName) print(f"Thanks for returning {bookName} book.") class Student: # def __init__(self): # print(self.book) def requestBook(self): self.book = input("\tEnter the book name which you want to issue : ") return self.book def returnBook(self): self.book = input("\tEnter the book name which you want to return : ") return self.book if __name__ == "__main__": rdLib = Library(["alogritms", "python", "c","javascript", "the little prince","java","HTML","CSS","Python editon 2"]) rdstd = Student() # rdLib.displayAvailableBooks() while True: welcomeMsg = '''\t*******Welcome to Rd Software Library*******\n\t Plz choose an option : \t1. List all the respected books \t2.Request a book \t3.Add or Return the book \t4.Exit the Library ''' print(welcomeMsg) userChoose = int(input("\tEnter the respected choose: ")) if userChoose==1: rdLib.displayAvailableBooks() print("\n\n") elif userChoose==2: rdLib.borrowBook(rdstd.requestBook()) print("\n\n") elif userChoose == 3: rdLib.returnBook(rdstd.returnBook()) print("\n\n") elif userChoose == 4: print("\tThanks for choosing Rd Software Library ......") exit() else: print("\tInVaild choice......")


 

Download Link for Source code file :


 










37 views0 comments

Recent Posts

See All

Comments


bottom of page