class 12 computer science project
class 12 computer science project
By Sampreethe.S, Mehanethra
XII-B
INDEX
1 INTRODUCTION 1
4 DESIGN WORK 6
7 CODE 10
8 OUTPUT 19
9 ADVANTAGES 27
10 FURTHER DEVELOPMENT 29
11 BIBLIOGRAPHY 31
INTRODUCTION
Libraries need a database system to help manage and organize their wide range of
materials, including books, journals, and digital content. A good database makes it
easy to find what patrons are looking for quickly and keeps everything well-
cataloged. It also simplifies important tasks like tracking loans, making operations
run more smoothly. Additionally, a database allows for advanced search options,
helping users discover resources more easily.
This project is a Python program that uses CSV (comma separated values) to create
a database to store details of the books in the library, helping librarians and the
public to easily enter, update, delete and view the details of the books, while also
being able to check whether or whether not a specific book has been loaned or not.
The system offers an intuitive user interface, making it easily accessible for non-
technical users and helps maintain efficiency which is important in a library.
1
OBJECTIVE:
The objective of a library database that allows users to create, delete, update, and
view details of books, as well as track who has borrowed specific titles, is to
enhance both resource management and user interaction. This system enables
librarians to efficiently add new books, remove outdated or damaged ones, and
update information like availability or catalog details.
MAIN FUNCTIONS:
1. Creating Book Entries: Users can easily add new books to the inventory by
giving needed information, such as title, serial no., author, genre, etc. This
function allows the details of new books to be added easily so that the
information can later be used/viewed.
2. Lending Books: This function can be used to lend books to the borrowers
and log in the details of which book is with whom. This makes it easier to
locate books efficiently without wasting time.
3. Update Book: Sometimes the details of a book might need to be changed or
modified, which is when this function is used. It allows users to modify the
certain records of a book without altering the entire entry. For example if the
price of a book must be changed, this function makes it easier to do that
without having to disturb any other detail.
2
4. Deleting Books: When a book is no longer available in the library, this
function makes it simple to delete the details of it from the database,
maintaining accuracy in the system.
5. Search For Books: This allows users to find and access the details of a
certain book without having to struggle and waste time. This function can
filter out the unnecessary books and show the ones that meet the exact
conditions provided.
6. Returning A Book: After finishing with a book, the borrower may come
back and return it for the use of others. In order to maintain accuracy about
which books have been returned or not, this function is used.
3
HARDWARE AND SOFTWARE REQUIREMENTS
HARDWARE
SOFTWARE
4
WHY PYTHON AND CSV ?
Python and CSV are commonly used for library databases due to their simplicity
and versatility. Python, with its user-friendly syntax and robust libraries like
Pandas, allows for easy manipulation of data, making it ideal for tasks such as data
entry, retrieval, and analysis.
Additionally, using Python with CSV files makes it easier for library staff to work
together and share information. By creating simple scripts, librarians can automate
everyday tasks, such as generating reports on book checkouts which saves time and
reduces mistakes. Python can also handle larger collections, making it simple for
libraries to grow as their number of books and users increases. This combination
not only streamlines library operations but also enhances the experience for library
visitors.
5
DESIGN WORK
System Design:
2. Data Storage: The system will store data in a CSV file, which will be used
to store information about books, users, and lending activities.
3. Data Access: The system will use the csv module to access and modify the
data in the CSV file.
4. Error Handling: The system will implement error handling to ensure that
the system can recover from errors and exceptions.
System Flow:
This is a high-level overview of the system design and flow. The specific
implementation details will depend on the requirements of the system and the
needs of the users.
6
• Create a new book: Prompt for
book details, validate input, and
add to CSV file.
7
CSV AND PYTHON FILES USED
CSV FILE:
library_management.csv
8
MODULES AND FUNCTIONS USED
MODULES:
csv: This module is used to read and write data to the CSV file.
FUNCTIONS:
9
CODE
import csv
CSV_FILE = 'library_management.csv'
def create_book():
book_data = {}
if field == 'lent_or_not':
book_data[field] = 'No'
book_data[field] = ''
else:
10
with open(CSV_FILE, 'a', newline='') as f:
cw = csv.writer(f)
def lend_book():
"""Lend a book"""
creader = csv.reader(f)
rows = list(creader)
for i in range(len(rows)):
if rows[i][0] == book_name:
print("Book found!")
if rows[i][4] == 'No':
rows[i][4] = 'Yes'
rows[i][5] = lenders_name
else:
11
print("Book is already lent!")
break
else:
cw = csv.writer(f)
cw.writerows(rows)
def search_book():
creader = csv.reader(f)
books = []
books.append(row)
if books:
print("Books found:")
print("---")
else:
def update_book():
13
book_name = input("Enter book name: ")
creader = csv.reader(f)
rows = list(creader)
for i in range(len(rows)):
if rows[i][0] == book_name:
print("Book found!")
print("Current details:")
for j in range(len(FIELD_NAMES)):
field_index = FIELD_NAMES.index(field_name)
if field_name == 'lent_or_not':
new_value = input("Enter new value for " + field_name + " (Yes/No): ")
else:
rows[i][field_index] = new_value
14
break
else:
cw = csv.writer(f)
cw.writerows(rows)
def delete_book():
creader = csv.reader(f)
rows = list(creader)
for i in range(len(rows)):
if rows[i][0] == book_name:
print("Book found!")
del rows[i]
break
else:
15
print("Book not found!")
cw = csv.writer(f)
cw.writerows(rows)
def return_book():
"""Return a book"""
creader = csv.reader(f)
rows = list(creader)
for i in range(len(rows)):
if rows[i][0] == book_name:
print("Book found!")
if rows[i][4] == 'Yes':
rows[i][4] = 'No'
rows[i][5] = ''
else:
16
print("Book is not lent!")
break
else:
cw = csv.writer(f)
cw.writerows(rows)
def main():
while True:
print("7. Exit")
if choice == '1':
17
create_book()
lend_book()
update_book()
delete_book()
search_book()
return_book()
break
else:
print("Invalid choice!")
main()
18
OUTPUT
19
RESULT:
20
SEARCH FOR BOOKS:
21
UPDATE BOOK:
RESULT:
22
DELETE BOOKS:
RESULT:
23
LEND BOOKS:
RESULT:
24
RETURN BOOKS:
25
EXIT:
26
ADVANTAGES
• Easy to Use: The code provides a simple and intuitive interface for users to
interact with the library database. It offers a menu-driven system that allows
users to perform various operations such as creating a new book, lending a
book, searching for books, updating a book, deleting a book, and returning a
book.
• Data Persistence: The code uses a CSV file to store the library data, which
means that the data is persisted even after the program is closed. This
ensures that the library data is safe and can be retrieved later.
• Data Validation: The code performs basic data validation to ensure that the
user input is correct. For example, it checks if the book name already exists
before creating a new book.
• Lending and Returning Books: The code allows users to lend and return
books, which is a critical feature for a library management system. It keeps
track of which books are lent and to whom, making it easy to manage the
library's inventory.
27
• Updating and Deleting Books: The code allows users to update and delete
book records, which is useful for maintaining the accuracy and integrity of
the library's data.
• Scalability: The code uses a CSV file to store the library data, which means
that it can handle a large number of books without significant performance
degradation. However, for very large libraries, a more robust database
solution may be necessary.
• Security: The code does not have any built-in security features, but it can be
modified to include authentication and authorization mechanisms to ensure
that only authorized users can access and modify the library data.
28
FURTHER DEVELOPMENT
2. Book Reservation System: Add a feature to allow users to reserve books that
are currently lent out. This can be done by adding a "reserved" field to the book
record and allowing users to reserve a book if it's currently lent out.
4. Book Reviews and Ratings: Allow users to leave reviews and ratings for books
they've read. This can help other users make informed decisions about which books
to read.
5. Book Availability Alerts: Implement a system that sends alerts to users when a
book they've reserved becomes available.
6. Library Branch Management: Add support for multiple library branches, each
with their own inventory of books. This can be done by adding a "branch" field to
the book record, and allowing users to search for books by branch.
7. Book Import and Export: Add features to import and export book data from
other sources, such as online bookstores or other library systems.
29
8. Reporting and Analytics: Implement a reporting system that provides insights
into library usage, such as most popular books, most active users, and book
circulation statistics.
9. Integration with Online Catalogs: Integrate the library database with online
catalogs like Goodreads or LibraryThing, allowing users to access more
information about books and authors.
10. Mobile App Development: Develop a mobile app that allows users to access
the library database and perform operations like searching for books, reserving
books, and checking out books.
13. Book Cover Images: Add support for storing book cover images, allowing
users to view the cover art for each book.
30
BIBLIOGRAPHY:
1. BOOKS:
• COMPUTER SCIENCE with python book for class XII by Sumita Arora
• COMPUTER SCIENCE with python book for class XI by Sumita Arora
2. WEBSITES:
• Geek for geeks
• W3Schools
3. YOUTUBE:
• freeCodeCamp
31