KEMBAR78
Pylibrary Kuldeep | PDF | Computer Programming | Software Engineering
0% found this document useful (0 votes)
19 views5 pages

Pylibrary Kuldeep

The document outlines a simple library management system implemented in Python. It allows users to borrow and return books, as well as view the current inventory of books in the library and those borrowed. The system operates in a loop until the user chooses to exit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views5 pages

Pylibrary Kuldeep

The document outlines a simple library management system implemented in Python. It allows users to borrow and return books, as well as view the current inventory of books in the library and those borrowed. The system operates in a loop until the user chooses to exit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

#4E) LIBRARY MANAGEMENT SYSTEM

CODE:-

library = ["Let us C", "Python", "Automata Theory", "Marvel"]

borrowedBooks =[]

def Borrow():

print(library)

BTB = input("Name of the book you want to borrow:- ").strip()

if BTB in library :

library.remove(BTB)

borrowedBooks.append(BTB)

print(f"You have borrowed {BTB}.")

else:

print("This book is currently unavailable at the library\nTry again later.")

def Return():

print(borrowedBooks)

RTL = input("Name of the book you want to return:- ").strip()

if RTL in borrowedBooks:

borrowedBooks.remove(RTL)

library.append(RTL)

print(f"You have returned {RTL}.")

else:

print(f"There is no book named {RTL} issued to you.\nCheck for spelling errors.")


def View():

print(f"Books in library:- {library}")

print(f"Books borrowed: {borrowedBooks}")

print("----------WELCOME TO KULDEEP’s LIBRARY----------")

while True:

print("Choose an option:-")

print("1)Borrow\n2)Return\n3)View\n4)Exit")

choice = input("Enter your choice:- ")

if choice == '1':

Borrow()

elif choice == '2':

Return()

elif choice == '3':

View()

elif choice == '4':

print("Thank you for visiting Kuldeep’s library.")

break;

else:

print("Invalid Choice!!!\n")

print("----------------------------------------------")
OUTPUT:-

----------WELCOME TO KULDEEP’s LIBRARY----------

Choose an option:-

1)Borrow

2)Return

3)View

4)Exit

Enter your choice:- 1

['Let us C', 'Python', 'Automata Theory', 'Marvel']

Name of the book you want to borrow:- Python

You have borrowed Python.

----------------------------------------------

Choose an option:-

1)Borrow

2)Return

3)View

4)Exit

Enter your choice:- 1

['Let us C', 'Automata Theory', 'Marvel']

Name of the book you want to borrow:- Let us C

You have borrowed Let us C.

----------------------------------------------

Choose an option:-

1)Borrow
2)Return

3)View

4)Exit

Enter your choice:- 3

Books in library:- ['Automata Theory', 'Marvel']

Books borrowed: ['Python', 'Let us C']

----------------------------------------------

Choose an option:-

1)Borrow

2)Return

3)View

4)Exit

Enter your choice:- 2

['Python', 'Let us C']

Name of the book you want to return:- Let us C

You have returned Let us C.

----------------------------------------------

Choose an option:-

1)Borrow

2)Return

3)View

4)Exit

Enter your choice:- 3

Books in library:- ['Automata Theory', 'Marvel', 'Let us C']


Books borrowed: ['Python']

----------------------------------------------

Choose an option:-

1)Borrow

2)Return

3)View

4)Exit

Enter your choice:- 4

Thank you for visiting Kuldeep’s library.

You might also like