0% found this document useful (0 votes)
13 views

CS Project

The document provides an overview of the Python programming language and its features. It then describes the hardware and software requirements for Python. It also includes a sample Python code for a basic library management system that demonstrates functions for adding books and students, issuing and returning books, and displaying records.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

CS Project

The document provides an overview of the Python programming language and its features. It then describes the hardware and software requirements for Python. It also includes a sample Python code for a basic library management system that demonstrates functions for adding books and students, issuing and returning books, and displaying records.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

INDEX

1 CERTIFICATE

2 ACKNOWLEDGEMENT

3 OVERWIEW OF PYTHON

HARDWARE AND SOFTWARE


4 REQUIREMENTS

5 CODING

6 OUTPUR

7 BIBILIOGRAPHY
ACKNOWLEDGMENT

It is with pleasure that i find myself penning down these lines to express my sincere thanks to
all those people who helped me a long way in completing this project

The harmonious climate in our school provided proper atmosphere for preparing the project. It
was a privilege to have been guided by Mrs.Padmini

I am also grateful to my classmates who helped me during the finalization of the project with
their constructive criticism and advice

COIMBATORE:

DATE:

OVERVIEW OF PYTHON
Python is a high-level, interpreted, interactive and object-oriented scripting language. Python is
designed to be highly readable. It uses English keywords frequently where as other languages
use punctuation, and it has fewer syntactical constructions than other languages.

● Python is Interpreted − Python is processed at runtime by the interpreter. You do


not need to compile your program before executing it. This is similar to PERL and
PHP
● Python is Interactive − You can actually sit at a Python prompt and interact with
the interpreter directly to write your programs.
● Python is Object-Oriented − Python supports Object-Oriented style or technique
of programming that encapsulates code within objects.
● Python is a Beginner's Language − Python is a great language for the beginner-
level programmers and supports the development of a wide range of applications
from simple text processing to WWW browsers to games.

PYTHON FEATURES

Python's features include −

● Easy-to-learn − Python has few keywords, simple structure, and a clearly defined
syntax. This allows the student to pick up the language quickly.
● Easy-to-read − Python code is more clearly defined and visible to the eyes.
● Easy-to-maintain − Python's source code is fairly easy-to-maintain.
● A broad standard library − Python's bulk of the library is very portable and cross-
platform compatible on UNIX, Windows, and Macintosh.
● Interactive Mode − Python has support for an interactive mode which allows interactive
testing and debugging of snippets of code.
● Portable − Python can run on a wide variety of hardware platforms and has the same
interface on all platforms.
● Extendable − You can add low-level modules to the Python interpreter. These modules
enable programmers to add to or customize their tools to be more efficient.
● Databases − Python provides interfaces to all major commercial databases.
● GUI Programming − Python supports GUI applications that can be created and ported
to many system calls, libraries and windows systems, such as Windows MFC, Macintosh,
and the X Window system of Unix.
● Scalable − Python provides a better structure and support for large programs than shell
scripting.

Apart from the above-mentioned features, Python has a big list of good features, few are listed
below −

It supports functional and structured programming methods as well as OOP.


It can be used as a scripting language or can be compiled to byte-code for building
large applications.
It provides very high-level dynamic data types and supports dynamic type checking.
It supports automatic garbage collection.
It can be easily integrated with C, C++, COM, ActiveX, CORBA, and JavA

HARDWARE AND SOFTWARE

REQUIREMENTS
Processors: Intel Atom processor or Intel Core i3 processor.

Disk space: 1 GB

Operating systems: Windows 7 or later, macOS, and Linux.

Python versions: 3.6X, 3.10X

Included development tools: Jupyter Notebook, Python IDLE, Visual Studio IDE, Pycharm
IDE

CODING

import mysql.connector
# Connect to the MySQL database
db = mysql.connector.connect(
host="localhost",
user="root",
password="N12345",
database="library"
)
# Create a cursor to interact with the database
cursor = db.cursor()

# Create the necessary tables if they don't exist


cursor.execute("CREATE TABLE books (id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(25))")
cursor.execute("CREATE TABLE students (id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(25),class_and_section VARCHAR (8)")
cursor.execute("CREATE TABLE transactions (id INT AUTO_INCREMENT PRIMARY
KEY, book_id INT, student_id INT, issue_date DATE, return_date DATE)")

# Function to add a book


def add_book():
book_name = input("Enter the name of the book: ")
query = "INSERT INTO books (name) VALUES (%s)"
values = (book_name,)
cursor.execute(query, values)
db.commit()
print("Book added successfully!")

# Function to add a student


def add_student():
student_name = input("Enter the name of the student: ")
student_class = input ("Enter the class and section of the student (in
roman numerals): ")
query = "INSERT INTO students (name,class_and_section) VALUES (%s ,
%s)"
values = (student_name,student_class)
cursor.execute(query, values)
db.commit()
print("Student added successfully!")

# Function to issue a book to a student


def issue_book():
book_id = input("Enter the ID of the book: ")
student_id = input("Enter the ID of the student: ")
query = "INSERT INTO transactions (book_id, student_id, issue_date)
VALUES (%s, %s, CURDATE())"
values = (book_id, student_id)
cursor.execute(query, values)
db.commit()
print("Book issued successfully!")

# Function to return a book


def return_book():
transaction_id = input("Enter the ID of the transaction: ")
query = "UPDATE transactions SET return_date = CURDATE() WHERE id =
%s"
values = (transaction_id,)
cursor.execute(query, values)
db.commit()
print("Book returned successfully!")

# Function to display the library's status


def display_status():
query = "SELECT transactions.id, books.name, students.name,
transactions.issue_date, transactions.return_date FROM transactions INNER
JOIN books ON transactions.book_id = books.id INNER JOIN students ON
transactions.student_id = students.id"
cursor.execute(query)
result = cursor.fetchall()

print("Transaction ID | Book Name | Student Name | Issue Date | Return


Date")

print("---------------------------------------------------------------")
for row in result:
print(f"{row[0]} | {row[1]} | {row[2]} | {row[3]} | {row[4]}")

#Function to edit student details


def student_details():
print("MENU FOR EDITING STUDENT DETAILS")
sdcasid=int(input('\n TO CHANGE STUDENT DETAILS, ENTER STUDENT ID
NUMBER:'))
query='SELECT * FROM STUDENT_INFO WHERE STUDENT_ID='.format(sdcasid)
cursor.execute(query)
if(query!=None):
print('''\n---------SUB MENU FOR CHANGING STUDENT DETAILS---------
\n[press 1]- TO EDIT STUDENT NAME (OR)
[press 2]- TO EDIT STUDENT CLASS AND SECTION (OR)
[press 3]- TO EDIT ISSUED BOOK NAME (OR)
[press 4]- TO EDIT BOOK ISSUE DATE (OR)
[press 5]- TO DELETE A SINGLE STUDENT DATA BY STUDENT ID
(KINDLY NOTE: STUDENT ID NUMBER CANNOT BE CHANGED ONCE SET.''')
sdca=int(input('ENTER HERE:'))
if sdca==1:
fne=str(input('\nENTER NEW/(CHANGING) STUDENT NAME;'))
unn='UPDATE TABLE STUDENT SET NAME= %s WHERE ID=%S'
unn1=(fne,sdcasid)
cursor.execute(unn,unn1)
db.commit()
print('STUDENT NAME UPDATED FOR STUDENT ID NUMBER',sdcasid)
elif(sdca==2): #change student class and sec
fnc=str(input('\nENTER NEW/(CHANGING)CLASS AND SECTION:'))
fncd='UPDATE TABLE STUDENT SET CLASS_AND_SECTION={} WHERE
ID={}'.format(fnc.sdcasid)
cursor.execute(fncd)
db.commit()
elif(sdca==3):
fnc=str(input('\nENTER NEW /CHANGING BOOK NAME:'))
fncd='UPDATE TABLE BOOKS SET NAME={} WHERE
ID={}'.format(fnc.sdcasid)
cursor.execute(fncd)
db.commit()
elif(sdca==4):
fnc=str(input('\nENTER NEW/(CHANGING) BOOK ISSUE DATE:'))
fncd='UPDATE TABLE TRANSACTION SET ISSUE DATE={} WHERE
STUDENT_ID={}'.format(fnc.sdcasid)
cursor.execute(fncd)
db.commit()
elif(sdca==5):
sdd=int(input('[press 1]-TO DELETE STUDENT DATA.THIS IS
PERMANENT DELETION:'))
if(sdd==1):
unn="DELETE from TRANSACTIONS WHERE STUDENT_ID=%s"
cursor.execute(unn.sdcasid)
db.commit()
print('STUDENT DATA DELETED FOR ID NUMBER.',sdcasid)

# Main menu
u=str(input("ENTER LIBRARIAN USERNAME:"));
print(u, "PLEASE ENTER YOUR PASSWORD (BELOW)")
lp=str(input("ENTER HERE:"))
lp1=lp.lower()
while lp1==("123456"):
print("\nPSGPS Library Management System")
print("------------------------------")
print("1. Add Book")
print("2. Add Student")
print("3. Issue Book")
print("4. Return Book")
print("5. Display Status")
print("6. Edit Student Details")
print("7. Exit")

choice = input("Enter your choice: ")

if choice == "1":
add_book()
elif choice == "2":
add_student()
elif choice == "3":
issue_book()
elif choice == "4":
return_book()
elif choice == "5":
display_status()
elif choice == "6":
student_details()
elif choice == "7":
break
else:
print("Invalid choice. Please try again.")

# Close the database connection


db.close()
OUTPUT

BIBILIOGRAPHY

● Computer Science with Python textbook (Sumita Arora)


● dataflair.learning

● codeprojects.org

You might also like