-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibraryManagementSystem.py
More file actions
65 lines (58 loc) · 2.19 KB
/
LibraryManagementSystem.py
File metadata and controls
65 lines (58 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
class Library:
def __init__(self, LibraryName, BookList=None, lb={}):
self.LibraryName = LibraryName
if BookList is None:
BookList = []
if BookList is not None:
self.BookList = BookList
if lb is not None:
self.lb = lb
def DisplayBooks(self, BookList):
for i, Book in enumerate(self.BookList, 1):
print(f"{i}. {Book}")
def AddBook(self, Book):
self.BookList.append(Book)
print(f"{Book} successfully added to the library")
def LendBook(self, Book, Owner):
self.BookList.remove(Book)
print(f"{Book} has been successsfully lend to {Owner}")
print(f"{Book} is no longer available in library")
self.lb.update({Book: Owner})
def ReturnBooks(self, Book, Owner):
self.BookList.append(Book)
print(f"{Book} has been recieved by {Owner}")
print("Thank you for returning the Book")
self.lb.pop(Book)
Name = input("What do you want to call your Library? ")
n = int(input("Number of books available in your library: "))
print("Enter the name of Books currently available in your Library: ")
lst = []
for i in range(n):
j = input("Book Name: ")
lst.append(j)
MyLibrary = Library(Name, lst)
ch1 = "y"
while(ch1 == "y" or ch1 == "Y"):
print("Library Management System")
print("1. Display Available Books")
print("2. Add Book in Library")
print("3. Lend Book from Library")
print("4. Return Back Book")
ch = 0
ch = int(input("Enter your Choice(1-4): "))
if ch == 1:
MyLibrary.DisplayBooks(lst)
elif ch == 2:
A_Book = input("Enter the name of the book to be added: ")
MyLibrary.AddBook(A_Book)
elif ch == 3:
B_Book = input("Enter the book to be lend: ")
Own1 = input("Enter the name of the owner: ")
MyLibrary.LendBook(B_Book, Own1)
elif ch == 4:
C_Book = input("Enter the book to be returned: ")
Own2 = input("Enter the name of the owner: ")
MyLibrary.ReturnBooks(C_Book, Own2)
ch1 = input("Do you Want to Continue(y/n)? ")
if ch1 == "n" or ch1 == "N":
exit