0% found this document useful (0 votes)
29 views29 pages

Library Management System in Python

The document describes a Library Management System software designed to manage library transactions and records efficiently. It includes features for entering and modifying book and student records, automatic fine calculations for late returns, and functionalities for issuing and depositing books. The system is user-friendly and aims to fulfill the requirements of librarians.

Uploaded by

isthismy5
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)
29 views29 pages

Library Management System in Python

The document describes a Library Management System software designed to manage library transactions and records efficiently. It includes features for entering and modifying book and student records, automatic fine calculations for late returns, and functionalities for issuing and depositing books. The system is user-friendly and aims to fulfill the requirements of librarians.

Uploaded by

isthismy5
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

4

General Description

Library Management System is a


software used to manage the
catalogue of a library. This helps to
keep the records of whole
transactions of the books available in
the library. Library Management
System which is very easy to use and
fulfills all the requirement of a librarian.
There are many features to keep
records of available books as well as
issued books...

5
Features provided by Program:

∙ Easy way to enter new books.


∙ Keep record of complete information
of books like; Book name, Author
name
∙ Easy way to make a check-out
∙ Automatic fine calculation for late
returns.
∙ Easy to enter new student record
∙ Easy way to modify or delete a
student/ book record
∙ And much more

6
Files Generated by
the Program
[Link]- File to
save Student
information
2. [Link]- File to
save book information
3. [Link]- File to
store issued book
information
Source
Code :
from pickle import load,dump

from os import remove,rename

import os

import random

import time

print()

print()

print()

print()

print()
print ("\t \t \t WELCOME TO THE PENTECOSTAL ASSEMBLY SCHOOL LIBRARY \t \t \t")

print()

print()

print()

print()

print()

print()

print ("\t \t \t \t \t \t \t PROJECT DONE BY : RITIKA GUPTA")

print()

print()

print("\t \t \t \t \t \t \......... ")

print()

print("\t \t \t \t \t \t \t……….. ")

print()

print()

a=input("PRESS ENTER TO CONTINUE:")

a=str(a)

if [Link]():

pass

"""**********************************************************************************

* CLASS USED IN PROJECT

***********************************************************************************""

" class book:

def __init__(self,bno=" ",bname=" ",auname=" "):

[Link]=bno

[Link]=bname

[Link]=auname

def create_book(self):
print()

print("\t\t\t Creating Book Record \t\t\t")

print()

[Link]=input("\t Enter Book Number:")

print()

[Link]=input("\t Enter Name of the Book:")

print()

[Link]=input("\t Enter Name of the Author:")

print()

print()

print("\t \t \t Book Created \t \t \t")

def show_book(self):
print()

print()

print("\t \t Book Number:",[Link])

print()

print ("\t \t Book Name:",[Link])

print()

print ("\t \t Author Name:",[Link])

print()

print()

def modify_book(self):

print()

print()

print ("\t \t Book No.: ",[Link])

print()

[Link]=input("\t \t Enter New Book Name:")

print()

[Link]=input("\t \t Enter New Author Name:")

print()
print()

print("\t \t Book Modified")

print()

def ret_bno(self):

return ([Link])

def report_book(self):

print([Link],[Link],[Link])

class student:

def __init__(self,admno=" ",name=" ",stbno=" ",token=0):

[Link]=admno

[Link]=name
[Link]=stbno

[Link]=token

def createstud(self):

print()

print("\t \t \t Creating Student Record \t \t \t")

print()

[Link]=input("\t \t Enter Admission Number:")

print()

[Link]=input("\t \t Enter Name of the Student:")

[Link]=" "

[Link]=0

print()

print()

print("\t \t \t Student Record Created \t \t \t")

print()

print("#"*70)

print()

def showstud(self):

print()

print()
print("\t Admission No.:",[Link])

print()

print("\t Name:",[Link])

print()

print ("\t Stbno:",[Link])

print()

print("\t Token:",[Link])

print()

def displaystud(self):

print()

print ("\t Admission Number of the Student is:",[Link])

print()

print ("\t Name of the Student is:",[Link]) if

([Link]==1):

print( "\t Book Number is:",[Link])

def modifystud(self):

print()

print ("\t Admission No:",[Link])

print()

[Link]=input("\t New Student Name:")

print()

print ("\t \t Student's Name Modified !!")

def ret_admno(self):

return [Link]

def ret_stbno(self):

return [Link]

def ret_token(self):

return [Link]

def add_token(self):
[Link]=1

def reset_token(self):

[Link]=0

def get_stbno(self,t):

[Link]=t

def reportstud(self):

print ([Link], [Link], [Link])

"""**********************************************************************************

* FUNCTION TO CREATE BOOK

***********************************************************************************""

" def writebook():

ch="Y"

fp=open("[Link]","ab")

while ch=="Y":

bk.create_book()

dump(bk,fp)

print()

ch=input("\t \t Do You Want to Continue<y/n>:")

print()

print ("#"*70)

print()

ch=[Link]()

"""***********************************************************************************
FUNCTION TO ENTER STUDENT RECORD

***********************************************************************************""

" def writestudent():

ch="Y"

fp=open("[Link]","ab")

while ch=="Y":

[Link]()

dump(st,fp)
ch=input("\t \t Do You Want to Continue <y/n>:")

ch=[Link]()

print()
"""**********************************************************************************

* FUNCION TO DISPLAY ALL STUDENT LIST

***********************************************************************************""

" def display_alls():

fin=open("[Link]","rb")

if not (fin):

print ("\t \t File is Not Found..")

else:

try:

while True:

print()

st=load(fin)

[Link]()

except EOFError:

pass

[Link]()

"""**********************************************************************************

* FUNCTION TO DISPLAY ALL BOOKS RECORD

***********************************************************************************""

" def display_allb():

fin=open("[Link]","rb")

if not (fin):

print()

print()

print ("Book File is Not Found..")

else:

try:

while True:
bk=load(fin)

bk.show_book()

except EOFError:

pass

[Link]()

"""**********************************************************************************

* FUNCTION TO DISPLAY PARTICULAR BOOKS RECORD

**********************************************************************************""

" def display_spb(no):

flag=0

fin=open("[Link]","rb")

try:

while True:

bk=load(fin)

if(bk.ret_bno()==no):

bk.show_book()

flag=1

except EOFError:

pass

[Link]()

if flag==0:

print()

print()

print ("\t \t \t \t BOOK NOT PRESENT..!!")

"""**********************************************************************************

* FUNCTION TO DISPLAY PARTICULAR STUDENT RECORD

**********************************************************************************""

" def display_sps(n):

flag=0

fin=open("[Link]","rb")
try:

while True:

st=load(fin)

if(st.ret_admno()==n):

[Link]()

flag=1

except EOFError:

pass

[Link]()

if flag==0:

print()

print ("\t \t \t STUDENT NOT PRESENT..!!")

"""**********************************************************************************

* FUNCTION TO MODIFY BOOK RECORD

***********************************************************************************""

" def modify_bookrecord():

found=0

print()

print()

print ("\t \t \t Modify Book")

print()

print()

n=input("\t \t Enter Book Number to be Modified:")

print()

fin=open("[Link]","rb")

fout=open("[Link]","wb")

try:

while True:

bk=load(fin)

if bk.ret_bno()==n:

print()
print ("\t \t \t Book Details")

bk.show_book()

print()

print("\t \t Enter New Details")

print()

print()

bk.modify_book()

dump(bk,fout)

found=1

else:

dump(bk,fout)

except EOFError:

pass

if found==0:

print("\t \t \t \t Book Not Present")

[Link]()

[Link]()

remove("[Link]")

rename("[Link]","[Link]")

"""***********************************************************************************
FUNCTION TO MODIFY STUDENT RECORD

**********************************************************************************””

” def modify_student_record():

found=0

print()

print("\t \t \t Modify Student Record")

print()

print()

n=input("\t \t Enter Student's Admission Number to be Modified:")

print()

fin=open("[Link]","rb")
fout=open("[Link]","wb")

try:

while True:

st=load(fin)

if st.ret_admno()==n:

print()

print("\t \t \t STUDENT DETAILS")

[Link]()

print()

print("\t \t \t Enter New Student Details:")

[Link]()

dump(st,fout)

found=1

else:

dump(st,fout)

except EOFError:

pass

if found==0:

print("\t \t \t \t STUDENT NOT PRESENT")

[Link]()

[Link]()

remove("[Link]")

rename("[Link]","[Link]")

"""**********************************************************************************

* FUNCTION TO DELETE STUDENT RECORD

**********************************************************************************""

" def del_stud():

flag=0

print()
print()

n=input("\t \t Enter Admission to be Deleted:")

print()

fin=open("[Link]","rb")

fout=open("[Link]","wb")

try:

while True:

st=load(fin)

if st.ret_admno()<n:

dump(st,fout)

else:

flag=1

except EOFError:

pass

[Link]()

[Link]()

remove("[Link]")

rename("[Link]","[Link]")

if flag==1:

print()

print("\t \t \t \t RECORD DELETED..!!")

else:

print()

print("\t \t \t \t SORYY..!! RECORD DOES NOT EXIST..!!..")

"""***********************************************************************************
FUNCTION TO DELETE BOOK RECORD

**********************************************************************************""
" def del_book():

flag=0

print()

print()

n=input("\t \t Enter Book No to be Deleted:")

print()

fin=open("[Link]","rb")

fout=open("[Link]","wb")

try:

while True:

bk=load(fin)

if bk.ret_bno()<n:

dump(bk,fout)

else:

flag=1

except EOFError:

pass

[Link]()

[Link]()

remove("[Link]")

rename("[Link]","[Link]")

if flag==1:

print( "\t \t \t Record Deleted")

else:

print("\t \t \t SORRY..!! RECORD NOT PRESENT..")

"""**********************************************************************************

* FUNCTION TO ISSUE BOOK

**********************************************************************************""

" def book_issue():

sn=" "

bn=" "
found=0

flag=0

print()

print()

print ("\t \t \t BOOK ISSUE.. \t \t \t")

print()

print()

sn=input("\t \t Enter the Student's Admission Number:")

print()

fin1=open("[Link]","rb")

fin2=open("[Link]","rb")

fout=open("[Link]","ab")

try:

while True:

st=load(fin2)

if (st.ret_admno()==sn):

[Link]()

found=1

if st.ret_token()==0:

bn=input("\t \t Enter Book Number:")

try:

while True:

bk=load(fin1)

if bk.ret_bno()==bn:

bk.show_book()

flag=1

st.add_token()

st.get_stbno(bk.ret_bno())

dump(st,fout)

[Link]("cls")

print()
print()

print("\t \t \t Book Issued Successfully \t \t \t")

print()

print("\t PLEASE NOTE : Write the current date in backside of your book ") print( "\t \t and

submit within 15 days")

print ()

print("\t \t Fine Rs.20 for each day after 15 days period..!!")

print()

except EOFError:

pass

else:

print("\t You have not returned the last book..")

except EOFError:

pass

"""***********************************************************************************
FUNCTION TO DEPOSIT BOOK

***********************************************************************************"""

def book_deposit():

print("\t \t \t BOOK DEPOSITING.")

sn=" "

found=0

flag=0

day=0

fine=0

print()

print()

sn=input("\t \t \t Enter Students Admission Number:")


print()

fin1=open("[Link]","rb")

fin2=open("[Link]","rb")

fout=open("[Link]","rb")

try:

while True:

st=load(fout)

if st.ret_admno()==sn:

found=1

print()

print("\t Student Token Number",st.ret_token()) if

st.ret_token()==1:

try:

while True:

bk=load(fin2)

if bk.ret_bno()==st.ret_stbno():

bk.show_book()

flag=1

print()

days=int(input("\t Book Deposited In no. of days:"))

if days>=15:

fine=(days-15)*20

print()

print("\t fine : Rs.",fine)

st.reset_token()

st.get_stbno(0)

[Link]()

print()

print("\t \t BOOK DEPOSITED !!!")


except EOFError:

pass

else:

print()

print("\t \t You have not issued the book..")

except EOFError:

pass

if(found==0):

print()

print("\t No Such Student Exists")

[Link]()

[Link]()

[Link]()

bk=book()

st=student()

"""**********************************************************************************

* ADMINISTRATOR MENU

**********************************************************************************""

" def adminmenu():

ch="Y"

while ch=="Y":

print()

print()

print ("\t \t \t ADMINISTRATION MENU \t \t \t")

print()

print()

print ("\t 1. CREATE STUDENT RECORD")

print()

print ("\t 2. DISPLAY ALL STUDENTS RECORD")

print()
print ("\t 3. DISPLAY SPECIFIC STUDENT RECORD")

print()

print ("\t 4. MODIFY STUDENT RECORD")

print()

print ("\t 5. DELETE STUDENT RECORD")

print()

print ("\t 6. CREATE BOOK")

print()

print("\t 7. DISPLAY ALL BOOKS")

print()

print("\t 8. DISPLAY SPECIFIC BOOK")

print()

print("\t 9. MODIFY BOOK")

print()

print("\t [Link] BOOK RECORD")

print()

ch1=int(input("\t \t Enter Your Choice:"))

print()

[Link]("cls")

if ch1==1:

writestudent()

elif ch1==2:

display_alls()

elif ch1==3:

print()

print()

ad=input("\t \t Enter Student's Admno to be Displayed:")

display_sps(ad)

elif ch1==4:

modify_student_record()

elif ch1==5:
del_stud()

elif ch1==6:

writebook()

elif ch1==7:

display_allb()

elif ch1==8:

print()

print()

bn=input("\t \t ENTER BOOK NUMBER TO BE DISPLAYED:")

display_spb(bn)

elif ch1==9:

modify_bookrecord()

elif ch1==10:

del_book()

print()

ch=input("\t \t Do you want Continue with ADMINMENU<y/n>:")

ch=[Link]()

print()

[Link]("cls")

if ch=="Y":

continue

else:

mainmenu()

"""**********************************************************************************

* MAIN MENU

**********************************************************************************""

" def mainmenu():

ch="Y"

while ch=="Y":

print()
print()

print("\t \t \t MAIN MENU \t \t \t")

print()

print("\t 1. BOOK ISSUE")

print()

print("\t 2. BOOK DEPOSIT")

print()

print("\t 3. ADMINISTRATION MENU")

print()

print("\t 4. EXIT")

print()

ch1=int(input("\t \t Enter Your Choice:"))

print()

print("\t \t Loading ....")

[Link]("cls")

if ch1==1:

book_issue()

elif ch1==2:

book_deposit()

elif ch1==3:

adminmenu()

else:

exit(0)

print()

ch=input("\t \t \t Do You Want to Continue <y/n>:")

ch=[Link]()

if ch=="N":

break

[Link]("cls")

[Link]("cls")
mainmenu()

OUTPUT
1. Introduction

2. Main Menu

31
3. Administration Menu

4. Issue Book
32
5. Deposit Book
Bibliography
Help from these resources
∙ Computer Science with Python – Sumita Arora
∙ [Link]
∙ [Link]
∙ [Link]

Common questions

Powered by AI

The system uses temporary files to ensure data integrity during operations like modifying or deleting records. For example, changes or deletions are first written to a temporary file (temp.dat), which then replaces the original data file. This approach prevents data loss by ensuring that if an error occurs during modification, the original file remains intact until the process is successfully completed .

The class structures, such as 'book' and 'student', form the foundation of the Library Management System by encapsulating the related properties and methods for each entity. The 'book' class handles attributes like book number, name, and author, and includes methods for creation, modification, and display of book records. Similarly, the 'student' class manages student information and its related processes. These classes enable modular and reusable code, making the system more organized and easier to maintain .

Challenges include inadequate validation of user input, such as incorrect data types or invalid entries, leading to potential operational errors. Error handling could be improved by implementing try-except blocks more extensively to catch input errors, adding checks for data integrity, and providing informative feedback to the user for corrective actions. Enhancements might include GUI replacements for textual input to ensure streamlined and constrained user interactions .

The system heavily utilizes encapsulation and modularity, fundamental object-oriented principles. The 'book' and 'student' classes encapsulate relevant attributes and methods, organizing the codebase and ensuring data hiding. Additionally, the principle of modularity is evident, as different functions like 'create_book', 'modify_book', and 'display_alls', isolate specific tasks, promoting code reusability and maintainability. However, inheritance and polymorphism are less prominently leveraged in the provided design .

Using binary files, such as book1.dat and student1.dat, allows for efficient storage and retrieval operations because binary format provides a compact means to store structured data without unnecessary overhead. This method supports direct serialization and deserialization of complex objects using Python's pickle module, ensuring quick access and modification of records. However, this approach lacks the robustness and querying power of a relational database, potentially complicating scalability and data integrity management .

The system uses textual prompts and menus to facilitate interactions, providing clear instructions for each operation. For instance, there are dedicated menus for different functionalities like the Main Menu and Administration Menu, guiding users through actions such as creating records, modifying data, and managing book issues and returns. User inputs are solicited for specific operations, ensuring a user-friendly interaction .

The system provides mechanisms for maintaining and updating records through functionalities that allow book and student data to be entered, modified, or deleted. Books and students have dedicated classes for handling their records, and the system utilizes functions like 'create_book', 'modify_book', 'createstud', and 'modifystud' for modifications. Persistent storage is managed via binary files (e.g., book1.dat and student1.dat), supporting database updates and maintenance .

The primary functions of the Library Management System include managing the catalog of a library, keeping records of book transactions, entering new books, maintaining complete information of books, calculating fines automatically for late returns, entering new student records, modifying or deleting student or book records, and issuing or returning books as outlined in the system's features .

The system calculates fines based on the number of late days by incorporating an automatic fine calculation process during the book return process. Specifically, it prompts the user to input the number of days since the book was issued. If this exceeds 15 days, a fine of Rs. 20 per late day is computed and displayed, ensuring fines are accurately managed based on defined criteria .

The system issues books by verifying the student's admission number and whether the student has any currently checked-out books using tokens. If no books are currently checked out (token=0), the book can be issued by entering the book number, after which the student's token is updated to reflect the checked-out status. For book returns, the token is checked to confirm the book number against the issued book, and fines are calculated if the return is late. Resetting the token status to 0 finalizes the return process .

You might also like