Python Mini Project #1 | Python Tutorials For Absolute Beginners In Hindi #71

preview_player
Показать описание


Best Hindi Videos For Learning Programming:

Follow Me On Social Media
Рекомендации по теме
Комментарии
Автор

class Library:
def __init__(self, book_list, library_name):
self.book_list = book_list
self.library_name = library_name
self.lend_record = {}

def display_book(self):
print(self.book_list)

def add_book(self):
book = input("Enter book name : ")
self.book_list.append(book)

def lend_book(self):
book = input("Enter book name : ").capitalize()
if book not in self.book_list:
print("Please enter valid input")
if book in self.book_list:
name = input("Enter your name : ")
self.book_list.remove(book)
self.lend_record[book] = name
else:
if self.lend_record.get(book):
print(f"Book does not exist in library this book taken by {self.lend_record[book]}")

def return_book(self):
book = input("Enter book name : ").capitalize()
if book in self.lend_record:
self.book_list.append(book)
del self.lend_record[book]
else:
print("Please enter valid input")

if __name__=='__main__':
book_list = ['C++', 'Java', 'JavaScript', 'Python']
karan_library = Library(book_list, 'karan_library')

while True:
user = input("\nD for Display book, A for Add book, L for lend book, R for return book, and Q for exit :")
if user == "Q" or user == "q":
break
elif user == "display" or user == "d" or user == "D":
karan_library.display_book()
elif user == "add" or user == "a" or user == "A":
karan_library.add_book()
elif user == "lend" or user == "l" or user == "L":
karan_library.lend_book()
elif user == "return" or user == "r" or user == "R":
karan_library.return_book()

karanchaudhari
Автор

Question given in video :
"""
Q-:You have to create a library management System . This must be done by creating a class called library

The class library should have the following functions:
1)display book: It displays all the books in the library along with wether they are available or lent to someone
2)lend book: This will allow the user to issue a book from the library. If the requested book is lent to someone
then print their name
3)add book: This fn is used to enter the name of the book to be added to the lib
4)return book : Allows the user to return a book

The Constructor of the class should take 2 arguments:
1) a list of all the book in the lib
2) the name of the lib

E.g:
HarryLibrary = Library(listofbooks, library_name)

You are to keep record of which book is issued to who via a dict as follows:
key - name of the book
value - name of the person issued to
dictionary (books-nameofperson)

create a main function and run an infinite while loop asking
users for their input"""

CHALLENGE ACCEPTED

rajatshukla
Автор

class library:
def display(self, name):
print("Welcome to"+name, end = "")
def lend(self, list):
print("Which book do you want?")
a = input()
print("tell your name")
name = input()
f = open("logs.txt", "a")
f.write("The person is :" +name+"\n")
print(f"{a} is now with you {name}")
return f"{list.remove(a)}"
def add(self, list):
print("Write the name you want to add")
a = input()
print("Succesfully added")
return list.append(a)
def retn(self, list):
print("What do you want to return")
a = input()
print("Your name")
name = input()
print("Done")
return list.append(a)

# Main Code
World_Library = library()
mainlist = [ "In Search of Lost Time", "Ulysses", "Don Quixote", "The Great Gatsby", "Harry Potter"]
World_Library.display(" 'World Library' ")
print(mainlist)
while True:
print("What do you want to do")
do = input()
if do == "lend":
World_Library.lend(mainlist)
elif do == "add":
World_Library.add(mainlist)
elif do == "return":
World_Library.retn(mainlist)

Soulsuki
Автор

12 years old and i am very happy that we have completed the object 200 programming think so i have made the mini project BAI dil tu banta ha yar aik din laga ha😀

OpGamerz-qzyz
Автор

I am highly interested to accept this challenge. 👍

ramaisgod
Автор

class Library:
def __init__(self, listofbooks, libraryname):
self.listofbooks = listofbooks
self.libraryname = libraryname

def display_book(self):
return f"The collection Of Books are: \n{self.listofbooks}\n"

def lend_book(self):
book_dic = {"The Dip":"Mr.Rayan"}
print()
user_name = input("Enter your name: ")
while True:
print(f"Choose Books from the menu:\n{self.listofbooks}")
print("Which Book You want to take?")
book_inp = int(input("Press 1, 2, 3, 4 Or 5:"))
if book_inp==0:
print("You are exit!!")
print("\n")
break
elif book_inp==1:
book_dic["Rich Dad Poor Dad"] = user_name
print("You Choose Rich Dad Poor Dad")
print("Press '0' to Exit")
print("\n")
elif book_inp==2:
book_dic["A scandal in bohemia"] = user_name
print("You choose A scandal in bohemia")
print("Press '0' to Exit")
elif book_inp==4:
print("\n")
elif book_inp==3:
book_dic["Irresistible"] = user_name
print("You choose Irresistible")
print("Press '0' to Exit")
print("\n")
book_dic["Gift of fear"] = user_name
print("You choose Gift of fear")
print("Press '0' to Exit")
print("\n")
elif book_inp==5:
print(f"This book is not available.Because it is own by", book_dic["The Dip"])
print("Press '0' to Exit")
print("\n")

def add_book(self):
no_of_books = int(input("How many books you want to add??.."))
count_book = 6
for i in range(1, no_of_books+1):
add_new = input("Enter name of book:")
self.listofbooks += f"\n{count_book}: {add_new}"
count_book+=1
print("\n")

def return_book(self):
return_book_name = input("Enter the name of book you want to return: ")
print(f"The book {return_book_name} has been returned.\nThank you..!!")
print("\n")

if __name__ == '__main__':
print(" LIBRARY MANAGEMENT SYSTEM")
books = "1: Rich Dad Poor Dad \n2: A Scandal in bohemia \n3: Irresistible \n4: Gift of fear \n5: The Dip"
Affan_lib = Library(books, "Engr.Affan Library")
while True:
print("Main Menu: \n1: Display Books \n2: Lend Books \n3: Add Books \n4: Return Books \n5: Exit")
task = int(input("Press 1, 2, 3, 4 or 5:"))
if task==5:
print("You are exit from Library..!!")
break
elif task==1:

elif task==2:
Affan_lib.lend_book()
elif task==3:
Affan_lib.add_book()
elif task==4:
Affan_lib.return_book()

appschoolss
Автор

Challenge accepted n excited for next tutorial series

namanbhandari
Автор

#mini project #1

class Library:
#constructor for initializing
def __init__(self, listofbooks, libname):
self.listofbooks=listofbooks
self.libname=libname
self.dictBook={}

#for displaying the books
def display(self):
print(f"List of Books in {self.libname}")
for index, item in enumerate(self.listofbooks):
print(f"{index+1}: {item}")

#for adding a new book to the Library
def add(self, str):
self.listofbooks.append(str)

#for lending a book
def lend(self, nameBook, nameUser):
if nameBook in self.listofbooks:
if nameBook in self.dictBook.keys():
print("Selected book is already issued to ", self.dictBook[nameBook])
else:
nameUser})
print("Issued Books: ", self.dictBook)
else:
print("----Entered book name is not correct----")

#for returning the book
def returning(self, str):
if str in self.listofbooks:
try:
self.dictBook.pop(str)
print("Issued Books: ", self.dictBook)
except:
print("----Entered book name is not lended yet----")
else:
print("----Entered book name is not correct----")



if __name__ == '__main__':
YogeshLibrary = Library(['7 Habits', 'Attitude is Everything', 'Mindful', 'Shastri jee', 'Steve jobs', 'Python'], "Yogesh Library")
while True:
print("Enter your choice")
print(" 1 for displaying the books")
print(" 2 for adding the books")
print(" 3 for lending the books")
print(" 4 for returning the books")
choice=input("Your choice, Sir :")

if choice=='1':
YogeshLibrary.display()

elif choice=='2':
newEntry=input("Enter the name of the new book: ")
YogeshLibrary.add(newEntry)
YogeshLibrary.display()

elif choice=='3':
nameBook = input("Enter the name of book you would like to lend: ")
nameUser = input("Enter the user who would like to lend: ")
YogeshLibrary.lend(nameBook, nameUser)

elif choice=='4':
str = input("Enter the name of book you would like to lend: ")
YogeshLibrary.returning(str)

elif choice=='0':
print("Thank you for visiting us")
exit(1)
else:
print("Entered choice is not correct")



##Date: 30 May 2020 :)

yogisharma
Автор

I have added some extra features like (book_serching, solve same book adding problem) and give very understanding code!

class Library:
def __init__(self, books, name):
self.books=books
self.name=name
self.dict={}

def display_book(self):
print("The available books are:")
for i in self.books:
print(i, end=", ")
print()

def lend_book(self):
person=input("Please enter your name: ")
want=input("Enter the book you want to lend :")
if want in self.books:
print("Ok, you can take it!")
self.dict[want]=person
self.books.remove(want)
elif want in self.dict:
taker=self.dict[want]
print(f"Sorry! it is already taken by {taker}")
else:
print("Sorry! we don't have such a book")

def add_book(self):
new=input("Hey Admin! Enter the book which you want to add: ")
if new in self.books:
print("This book is already present! please add another book...")
elif new in self.dict:
print("This book is already present in our library and taken by someone")
else:
print("Adding....")
self.books.append(new)
print("Successfully added!")

def return_book(self):
ret=input("Enter the book name: ")
if ret in self.dict:
self.dict.pop(ret)
self.books.append(ret)
print("Successfully returned")
elif ret in self.books:
print("You have not issued it!")
else:
print("We dont have such books!")

def search_book(self):
find = input("Enter book name to check whether it is available or not: ")
print("Searching...")
if find in self.books:
print("oh! great, this book is available in our library.")
elif find in self.dict:
print("This book is available in our library but currently issued by someone plz wait until its available for you...")
else:
print("sorry we don't have such books!")

name = "\n*** Welcome To the Anupam Library ***"

l1=Library(["Python", "java", "C", "C++", "NodeJS", "Web Dev", "javascript"], name)
print(l1.name)

while True:
inp=(input("\nenter 1 to display books: \nenter 2 to lend a book: \nenter 3 to add a new book: \nenter 4 to return a book: \nenter 5 to search a book: \nenter 6 to exit: \n"))
if inp == '1' or inp == 'D' or inp == 'd':
l1.display_book()
elif inp == '2' or inp == 'L' or inp == 'l':
l1.lend_book()
elif inp == '3' or inp == 'A' or inp == 'a':
l1.add_book()
elif inp == '4' or inp == 'R' or inp == 'r':
l1.return_book()
elif inp == '5' or inp == 'S' or inp == 's':
l1.search_book()
elif inp == '6' or inp == 'E' or inp == 'e':
print("\t\t *** Thanks for Using our facility! ***")
break
else:
print("Invalid input!")

thetechgalaxy
Автор

class Library:
dic = {}
def __init__(self, listofbooks, library_name):
self.listofbooks = listofbooks
self.library_name = library_name

def displaybook(self):
print("The books in library are\n")
n=1
for i in self.listofbooks:
print(n, ". ", i)
n+=1

def lendbook(self):
global lender_name
lender_name = input("Enter your name:- ")
global lend_book
lend_book = input("Enter the book name for taking at rent:- ")
if lend_book in self.listofbooks:


print(f"The {lend_book} book is succesfully taken by to {lender_name}\n")
else:
print("The book are not available in library\n")
def addbook(self):
add_book = input(f"Enter the books to add in library {self.library_name}\n")
add_book = add_book.split(", ")
for i in add_book:
if i != lend_book:
self.listofbooks.append(i)
print("your books are succesfully added")

def returnbook(self):
return_book = input(f"Enter the books to return in library {self.library_name}\n")
if return_book == lend_book:

print(f"The {return_book} book has succesfully return in library\n ")
else:
print("Enter valid book ")

def find_book(self):
find = input("Enter the book name:- ")
if find in self.listofbooks:
print(f"The book {find} is available in library")
elif find in self.dic:
print(f"The book {find} is given to {self.dic[find]}")
else:
print("The book are not available")
book = ["DEATH NOTE"]

mohit_lib = Library(book, "knowledge temple")
object = mohit_lib

while True:
try:
prog = input("press 1 for access the library press 0 for exit the library\n")
if int(prog) == 1:
access = input("Print 'D' for Display the books \nPrint 'L' for Lend the book \n"
"Print 'A' for Add the books \nPrint 'R' for Return the books \n"
"print 'F' for find the book\n")
if access == "D" :
object.displaybook()
elif access == "L" :
object.lendbook()
elif access == "A" :
object.addbook()
elif access == "R" :
object.returnbook()
elif access =="F":
object.find_book()
else:
break
except Exception as e:
print(e)

mk_art
Автор

# Question given in video :
"""
Q-:You have to create a library management System . This must be done by creating a class called library

The class library should have the following functions:
1)display book: It displays all the books in the library along with wether they are available or lent to someone
2)lend book: This will allow the user to issue a book from the library. If the requested book is lent to someone
then print their name
3)add book: This fn is used to enter the name of the book to be added to the lib
4)return book : Allows the user to return a book

The Constructor of the class should take 2 arguments:
1) a list of all the book in the lib
2) the name of the lib

E.g:
HarryLibrary = Library(listofbooks, library_name)

You are to keep record of which book is issued to who via a dict as follows:
key - name of the book
value - name of the person issued to
dictionary (books-nameofperson)

create a main function and run an infinite while loop asking
users for their input"""


import threading
from threading import Thread

class Library:
dicti = {} # for storing lented books ad the name lented to
# lent_list = []
def __init__(self, booklist, name):
self.booklist = booklist
self.name = name


# def lentlistupdate(self):
# for i in self.dicti.keys():
# for j in self.booklist:
# if i==j:
# self.lent_list.append(i)


def booklistupdate(self):
for book in self.booklist:
if book in self.dicti.keys():
self.booklist.remove(book)




def display_books(self):
print(f"Available books are {self.booklist}")
for i in self.dicti.keys():
print(f"{i} is lent out to {self.dicti[i]}")




def lend_book(self):
bookname = input("which book you want to lent?\n")
if bookname in self.booklist:
name = input("Enter your name\n")
self.dicti[bookname] = []

print('The book has benn issued to you.')
else:
print("The book is either lent out or not present in this library")
self.runall()

def addbook(self):
bookname = input("Tell name of the book\n")

print("Thanks for your donation")

def returnbook(self):
bookname = input("Tell name of the book to return")
if bookname in self.dicti.keys():
self.dicti.pop(bookname)

else:
print("This book doesn't belong to this library")

def runall(self):
if __name__ == '__main__':
#Thread(target = self.lentlistupdate).start()
Thread(target = self.booklistupdate).start()





harry = Library(["a", "b", "c"], "harry")

# harry.display_books()
#harry.lend_book("a")
# print(harry.dicti)

choice = "y"
while choice in ["Y", "y"]:
choice_2 = int(input("What you wanna do:\n 1.Display books \n 2.Lent book \n 3.add book \n 4.Return book\n"))
if choice_2 ==1:
harry.display_books()

elif choice_2 == 2:
harry.lend_book()

elif choice_2 ==3:
harry.addbook()

elif choice_2 ==4:
harry.returnbook()

else:
print("Wrong Choice")

choice = input("type Y if you want to run program again\n")

helpinghand
Автор

var = 1
class library:
def __init__(self, name_library, list_of_books):
self.library_name = name_library
self.library_books = list_of_books
def display_books_func(self):
global var
for books in self.library_books:
print(f"{var}-{books}")
var = var + 1
var = 1
to_return = input("Do you want to return to main menu: ")
if to_return == "y" or to_return == "yes":
to_recall_again()
else:
quit()
def add_books_func(self):
book_to_add = input("Enter The Name Of Book To Add: ")


print(f"Thanks for donating {book_to_add} to our library")
to_return = input("Do you want to return to main menu: ")
if to_return == "y" or to_return == "yes":
to_recall_again()
else:
quit()
def lend_lib_books(self):
global var, lend_books
for books in self.library_books:
print(f"{var}- {books}")
var = var + 1
var = 1

print("Among Them Which Book do you want to lend(Enter the book name correctly)")
lending_book = input()
number_of_book = int(input("Enter The Number at front of book"))


to_return = input("Do you want to return to main menu: ")
if to_return == "y" or to_return == "yes":
to_recall_again()
else:
quit()
def return_book_lib(self):
global var, lend_books
print("These are list of lended books")
for person in lend_books:
print(f"{var}- {person} {lend_books[person]}")
var = var + 1
var = 1

print("Enter The Book To Return")
return_book_name = input()
del lend_books[return_book_name]

to_return = input("Do you want to return to main menu: ")
if to_return == "y" or to_return == "yes":
to_recall_again()
else:
quit()
def
print("These are list of lended books")
for person in lend_books:
print(f"{var}- {person} {lend_books[person]}")
var = var + 1
to_return = input("Do you want to return to main menu: ")
if to_return == "y" or to_return == "yes":
to_recall_again()
else:
quit()

lend_books = {}
display_books = ["My Hero Academia Vol 1", "Spider Man Homecomming", "One piece vol 1 ", "Harry Potter the soccers stone", "Death Note"]
return_books = []
which_person_which_book = {}
deku_library = library("Deku's Library", display_books)
name_of_person = input("Enter your name to register in the library: ")
def to_recall_again():
global what_to_do, var
var = 1
print(f"Welcome {name_of_person} to Deku's Library: ")
print("1 Add Book To Library")
print("2 Lend A Book")
print("3 Return A Book")
print("4 Display All Books")
print("5 Which person has lended which book")
what_to_do = int(input())
if what_to_do == 1:

if what_to_do == 2:

if what_to_do == 3:

if what_to_do == 4:

if what_to_do == 5:

var = 1
to_recall_again()

CodeHackers
Автор

class library:
lendbook = {"harry potter": "ROHAN"}

def __init__(self, library_name, *booksname):
self.library_name = library_name
self.book1 = booksname[0]
self.book2 = booksname[1]
self.book3 = booksname[2]
self.book4 = booksname[3]


def displaybooks(self):
for i in booksname:
print(i)


def lend(self):
self.var = input("enter a book you want to lend\n")
if self.var not in booksname:
print("NOT AVAILABLE IN THE BOOKSTORE")
elif self.var in self.lendbook:
print(f"book is taken by choose another book")
else:
print(f"you have lend the book ({self.var})")
self.lendbook.setdefault(self.var, "NARUTO")

def addbook(self):
n = input("ENTER THE BOOK NAME THAT YOU WANT TO DONATE\n")
booksname.append(n)
print("SUCESSFULLY DONATED")

def returnbook(self):
print(f"these are the books which are to be returned:\n"
f"{self.lendbook.keys()}")
n = input("TYPE THE NAME OF THE BOOK YOU WANT TO RETURN\n")
if n in self.lendbook:
print("thanks for returning the book")
self.lendbook.pop(n)

def main(self):
while True:
n = int(input("press 1 for books display\n"
"press 2 for lend book\n"
"press 3 for adding a book\n"
"press 4 for returning book\n"
"press 5 for exiting the Ronnie's Library\n"))
if n == 1:
self.displaybooks()
if n == 2:
self.lend()
if n == 3:
self.addbook()
if n == 4:
self.returnbook()
if n == 5:
print("STUDY HARD\n"
"...BYE....\n"
"COME AGAIN SOON")
break

booksname = ["harry potter", "sherlock holmes", "meluha", "half girlfriend"]
ronnie = library("Ronnie's library", *booksname)
ronnie.main()

adityamehta
Автор

class Library:

def __init__(self, listofbooks, nameoflibrary):
self.books=listofbooks
self.name=nameoflibrary
self.lenders = dict()
def displaybooks(self):
print("We Have Following books in Our Library")
for i, value in enumerate(self.books):
print(f"{i+1}--->{value}\n")
def lendbooks(self):
nameoflender=input("Please enter your name")
self.displaybooks()
book=int(input("Enter the book no you want to LEND"))
if book in self.lenders.keys():
print(f"Sorry book in unavailable it is taken by {self.lenders[book]}")
else:

def returnbook(self):
self.displaybooks()
book=input("Enter which book you want to return")
del
def addbook(self):
book=input("Enter the the book you want to add ")
self.books.append(book)

if __name__ == '__main__':
var=Library(["No Excuse", "Millionare Fastlane"], "Shivam'sLibrary")
while(True):
print(f"Welcome to {var.name}\n")
print("Enter what you want:-")
choice=int(input("1.Display Books\n2.Lend
if choice==1:
var.displaybooks()
elif choice==2:
var.lendbooks()
elif choice==3:
var.returnbook()
elif choice==4:
var.addbook()

shivammishra
Автор

I will do this DEFINITLY. i started watching your video last month and it's awesome harry bhai...

_saurabhkumar
Автор

# To create a library for humans.

class Library:

def __init__(self, name, mode):
self.user = name
self.Mode = mode

@staticmethod
def display(boko):
i = 0
while i < len(boko):
print(f"{i + 1}: {boko[i]}")
i += 1

def rent_book(self, boko):

f = open("rent.txt", "r+")

final_data = {}

data = f.readlines()
x = len(data)

for i in range(x):
uno = data[i]
special_data = uno.split("--")
book = special_data[1]
name_book = book.split("\n")
name_of_book = name_book[0]
final_data[special_data[0]] = name_of_book

for key in final_data:
boko.remove(final_data[key])

self.display(boko)
r_number = int(input("Please enter the book number you want to rent: "))
r_book = boko[r_number - 1]

sign_in = list(final_data.keys())

if self.user in sign_in:
print(f"Please return the book {final_data[self.user]}\nOnly then new book will be issued.")

elif self.user not in sign_in:

print(f"You have been rented the book of '{final_data[self.user]}'")
boko.remove(r_book)

elif r_book not in boko:
print(f"Book {r_book} not in stock right now.")

f.close()

def return_book(self):

final_data = {}

with open("rent.txt") as f:
data = f.readlines()
x = len(data)

for i in range(x):
uno = data[i]
special_data = uno.split("--")
book = special_data[1]
name_book = book.split("\n")
name_of_book = name_book[0]
final_data[special_data[0]] = name_of_book

sign_in = list(final_data.keys())

if self.user in sign_in:
ret_input = int(input(f"{self.user} have '{final_data[self.user]}'\nDo you wish to return it\n"
"Press 1 for YES and 0 for NO: "))

if ret_input == 1:
del final_data[self.user]
with open("rent.txt") as f:
con = f.read()
with open("rent.txt", "w") as g:
for keys in final_data:

print(f"The book '{final_data[self.user]}' has been returned. ")

else:
print("OK")


def donate_book(self, boko):
d_book = input("Please enter the name of book you wish to donate: ")
boko.append(d_book)


all_books = ["In Search of Lost Time", "Ulysses", "Don Quixote", "One Hundred Years of Solitude",
"The Great Gatsby", "Moby Dick", "War and Peace", "Hamlet", "The Odyssey",
"Madame Bovary"]

while 1:
user_name = input("Please enter your name: ")
user_name.capitalize()
user_mode = int(input("Type:\n1 for display\n2 for rent\n3 for donate\n4 for return: "))

Kanav_library = Library(user_name, user_mode)

if user_mode == 1:
print()
print()


elif user_mode == 2:
print()
print()


elif user_mode == 3:
print()
print()


elif user_mode == 4:
print()
print()
Kanav_library.return_book()

kanavsingla
Автор

Done project!!

# create a lib class
# lending - who owns the book if not present in the lib
# adding
# return book
# display book

import time
class Library:

# Initializing the booklist and the dicionary for adding the nams of people who took the books and also the library name
def __init__(self, booklist, libname, lentbooks=None, availablebooks=None):
self.booklist = booklist
self.libname = libname
self.lentbooks = lentbooks
self.availablebooks = availablebooks
self.lentbooks = {}
self.availablebooks = self.booklist

# Function for adding the book

def addbook(self):
# ask deyail of the book
name_of_book = input("\nEnter the name of the book: ").lower()

# Enters the name of the book in the list of available books

time.sleep(1.5)
print("Book added! \n")


# Function for lending book
def lendbook(self):
# Print out the list of available books
print("List of available books:")
print("\n", self.availablebooks)

# ask details
name_of_book = input("\nEnter the name of the book: ").lower()
name_of_lender = input("Enter the name of the person: ").lower()

# if the book asked is not present in the available book list then show a message that the book is not available
if name_of_book not in self.availablebooks:
time.sleep(1.5)
print("Book not available!")

else:
# add the book name and lender name to the dictionary
name_of_book})
# remove the particular book from availablebooks list


# prints thankyou message
time.sleep(1.5)
print("Thank you for borrowing from us! \n")


# function to return the book to the library
def returnbook(self):

# ask the details for the person and the book
name_of_book = input("\nEnter the name of the book: ").lower()
name_of_lender = input("Enter the name of the person: ").lower()

# If the details of the person and the book match then we remove the book and the person from the lentbooks dictionary and add that book to the avaialablebooks list
if (name_of_lender, name_of_book) in self.lentbooks.items():



# prints the message that the book was returned
time.sleep(1.5)
print("Book returned!\n")
else:
print("This person did not take this book \n")

# Displays the list of available books
def displaybooks(self):
print("List of available books are:")
print(self.availablebooks)


if __name__ == "__main__":
ayon = Library(['a', 'b', 'c', 'paradisal femininty', 'zephyr to my burning soul'], 'ayonlib')

print("Press 1 for adding book \nPress 2 for lending book \nPress 3 for returning book \nPress 4 for displaying the list of available books")

truthvalue = True
while truthvalue:
choice = input("\nEnter your choice: ")

if choice == "1":
ayon.addbook()

elif choice == "2":
ayon.lendbook()

elif choice == "3":
ayon.returnbook()

elif choice == '4':
ayon.displaybooks()

else:
print("Invalid choice!")

# Leaving the library logic
print("Do you want to leave the library")
decision = input("\nEnter Y/y or Yes and press any key to continue... ")
if decision == 'Y' or decision == "y":
print('\n \nThank you for using our library!')
truthvalue = False
else:
print("")

Ayon-cmsj
Автор

class library:
dic={}
un = "None"
list_of_book = ["Harry potter volume 4", "C++ for beginners", "Tell Me Your Dreams", "To Kill a Mockingbird", "Encyclopedia Britannica", "100 greatest people", "The Theory of Everything"]
for index, value in enumerate(list_of_book):
dic[list_of_book[index]] = un

def __init__(self):

self.ln="VM Library"
#self.dic

@property
def display_book(self):
for book in library.list_of_book:
print(book)

def lend_book(self, username):
choose_book=str(input("Enter book name to lend\n"))
if choose_book in library.list_of_book and

print("Book rented")
elif choose_book in library.list_of_book and
print(f"Book is not available, currently lended by {library.dic[choose_book]}")
else:
print("Wrong Book Title Entered")
def return_book(self):

choose_book =str(input("Enter book name to return\n"))
if choose_book in library.list_of_book and

print("thank You for using our Retured")
elif choose_book in library.list_of_book and
print("Sorry you cant return the book that has yet not been borrowed")
else:
print("Wrong Book Title Entered")
def donation(self, username):

book_name=str(input("Enter Book title to donate to our collection\n"))

library.dic[book_name] =library.un
print(f"Thankyou for your donation {username}.. We really appreciate it\n")


while(True):
def exit_function():
print("\nPress\n1 to go to previous menu\n2 to exit\n")
input_3 = int(input())
if input_3 == 1:
return
elif input_3 == 2:
global while_var
while_var = 2

while_var=1
input_1=input("Enter your username\n")
username=input_1
input_1=library()
while(while_var!=2):
input_2= int(input("Press\n1 to display books\n2 to lend book\n3 to return book\n4 to donate book\n"))
if input_2==1:
input_1.display_book
print("\nPress\n1 to go to previous menu\n2 to exit\n")
input_3=int(input())
if input_3==1:
continue
elif input_3==2:
while_var = 2
elif input_2==2:
#print(input_1.dic)
input_1.lend_book(username)
exit_function()
elif input_2==3:
input_1.return_book()
exit_function()
elif input_2==4:
input_1.donation(username)
exit_function()

umar
Автор

class Library:
def __init__(self, listofbook, lib_name):
self.books = listofbook
self.library_name = lib_name
self.books_info = {}
to

def display_book(self):
for i, j in enumerate(self.books):
print(i+1, "-", j)

def available_books(self):
print("available books...")
for i, j in enumerate(self.books):
print(i+1, "-", j)

def lend_book(self, bookname):
std_name = input("Enter your name: ")
self.student_name = std_name
self.bookname = bookname
if bookname in self.books_info:
print(f"the book is lended to
else:

print(self.books_info)
self.books.remove(bookname)
print("Thank you for lending book from us...")

def add_book(self, nameofbook):

print(self.books)

def return_book(self, bookname):

print(self.books_info)

harrylibrary = Library(["Python book", "java book", "c prog book", "c++ book"], "HarryLibrary")
while(1):
a = int(input("Enter 1 to displaybooks, "
" 2 to lend, 3 to add, "
" 4 to return book, "
" 5 to quit: "))
if a ==1:
harrylibrary.display_book()
print("\n")

elif a == 2:

lend = input("Enter the book name you want to lend: ")
harrylibrary.lend_book(lend)
print("\n")

elif a == 3:
add_book = input("Enter the book name you want to add: ")

print("Your book has been added")
harrylibrary.display_book()
print("\n")

elif a == 4:
ret_book = input("Enter the book name you want to return: ")

print("thank you... your book has been returned")
print("\n")

elif a==5:
break

else:
print("Wrong input..")
print("\n")

gamingwithtanmay
Автор

Bro you are doing such a great job, Thank you so much

himanshubansal
welcome to shbcf.ru