You are on page 1of 19

PM SHRI

KENDRIYA VIDYALAYA
KHANAPARA
PROJECT REPORT
ON

Phone Contact Management

SUBJECT: COMPUTER SCIENCE (083)

SUBMITTED BY: SUBMITTED TO:

ROLL NO : 26 DR. VIMAL KUMAR SONI


NAME : Siddharth Rahang PGT (COMPUTER SCIENCE)
ROLL NO : 27 PM SHRI KENDRIYA VIDYALAYA
NAME : Udayan Saikia KHANAPARA, GUWAHATI
CLASS : XII
SECTION :A

1
TABLE OF CONTENTS

TOPIC PAGE NO.


Acknowledgement 3
Certificate by Guide 4
Certificate by Examiner 5
Introduction to the Project 6-8
Detail of Features of the Project 9
Project Specification 10
Project Code 11-13
Output 14-16
Conclusion 17
Bibliography 18

2
ACKNOWLEDGEMENT

We would like to express our sincere gratitude to all those who have
contributed to the successful completion of this computer science
project.

First and foremost, I would like to thank our computer science teacher
Dr. Vimal Kumar Soni for providing valuable guidance and support
throughout the project. Your insights and feedback were instrumental in
shaping the direction of our work.

We extend our appreciation to our classmates who engaged in


thoughtful discussions, shared ideas, and provided valuable input that
greatly enriched the project. Collaborating with such a dedicated and
enthusiastic group has been an enriching experience.

Special thanks go to our family for their unwavering support and


encouragement. Your belief in our abilities motivated us to overcome
challenges and strive for excellence.

Last but not least, we are grateful to the entire school community for
fostering an environment that encourages exploration and learning. The
resources and opportunities provided have been crucial in the
development and execution of this project.

Thank you to everyone who played a role in this endeavor. Your support
has been invaluable, and we are truly grateful for the collaborative spirit
that made this project a success.

3
CERTIFICATE BY GUIDE

This is to certify that the project entitled


Phone Contact Management

has been completed under my guidance and project report is submitted by


following students –

Udayan Saikia, XII A


Siddharth Rahang, XII A

The report is the result of his/her/their consistent efforts and endeavors. The
report is found worthy of acceptance as final project for the subject
COMPUTER SCIENCE (083) of Class XII Session 2023-24.

PGT Computer Science Principal

PM SHRI KV KHANAPARA

4
5
CERTIFICATE BY EXAMINER

The project report entitled


“Phone Contact Management’’,
Submitted by
Udayan Saikia, XII A
Siddharth Rahang, XII A

of PM SHRI KV KHANAPARA for COMPUTER SCIENCE (083) at PM


SHRI Kendriya Vidyalaya Khanapara, Guwahati has been checked and
examined.

Examiner

6
INTRODUCTION TO THE
PROJECT
This project is basically made for the management of:
Phone contacts

ABOUT PYTHON:
Python is an interpreted, object-oriented, high-level programming
language with dynamic semantics. It's high-level built- in data
structures, combined with dynamic typing and dynamic binding,
makes it very attractive for Rapid Application Development, as well
as for use as a scripting or glue language to connect existing
components together. Python's simple, easy to learn syntax
emphasizes readability and therefore reduces the cost of program
maintenance. Python supports modules and packages, which
encourages program modularity and code reuse. The Python
interpreter and the extensive standard library are available in source or
binary form without charge for all major platforms, and can be freely
distributed.

Often, programmers fall in love with Python because of the increased


productivity it provides. Since there is no compilation step, the edit-
test-debug cycle is incredibly fast. Debugging Python programs is
easy: a bug or bad input will never cause a segmentation fault.
Instead, when the interpreter discovers an error, it raises an exception.
When the program doesn't catch the exception, the interpreter prints a
stack trace. A source level debugger allows inspection of local and
global variables, evaluation of arbitrary expressions, setting
breakpoints, stepping through the code a line at a time, and so on. The
debugger is written in Python itself, testifying to Python's
introspective power. On the other hand, often the quickest way to
debug a program is to add a few print statements to the source: the
fast edit-test-debug cycle makes this simple approach very effective.
7
ABOUT MYSQL:

MySQL is the world’s most popular open source


database. According to DB-Engines, MySQL ranks as
the second-most-popular database, behind Oracle
Database. MySQL powers many of the most accessed
applications, including Facebook, Twitter, Netflix,
Uber, Airbnb, Shopify, and Booking.com.
Since MySQL is open source, it includes numerous
features developed in close cooperation with users over
more than 25 years. So it’s very likely that your favorite
application or programming language is supported by
MySQL Database.
MySQL is a relational database management system
Databases are the essential data repository for all
software applications. For example, whenever
someone conducts a web search, logs in to an account,
or completes a transaction, a database system is
storing the information so it can be accessed in the
future.
A relational database stores data in separate tables
rather than putting all the data in one big storeroom.
The database structure is organized into physical files
optimized for speed. The logical data model, with
objects such as data tables, views, rows, and columns,
offers a flexible programming environment. You set up
rules governing the relationships between different
8
data fields, such as one to one, one to many, unique,
required, or optional, and “pointers” between different
tables. The database enforces these rules so that with
a well-designed database your application never sees
data that’s inconsistent, duplicated, orphaned, out of
date, or missing.
The “SQL” part of “MySQL” stands for “Structured
Query Language.” SQL is the most common
standardized language used to access databases.
Depending on your programming environment, you
might enter SQL directly (for example, to generate
reports), embed SQL statements into code written in
another language, or use a language-specific API that
hides the SQL syntax.

MySQL is open source


Open source means it’s possible for anyone to use and
modify the software. Anybody can download MySQL
software from the internet and use it without paying
for it. You can also change its source code to suit your
needs. MySQL software uses the GNU General Public
License (GPL) to define what you may and may not do
with the software in different situations.

9
DETAILS OF
FUNCTIONALITIES /FEATURES
OF THE PROJECT

In this project we can

1.Add contact
2.Change the phone number of the contact
3.Delete a contact
4.Display all contacts
5.Display all contacts in sorted manner
6.check whether a contact exist

10
PROJECT SPECIFICATIONS

Python Module(s) used in the project –

1. ‘MySQL. Connector. connect’: This function is used to create a connection to


the MySQL server.

2. ‘cursor’: This is an object created using conn.cursor() that is used to execute


SQL queries and fetch results.

3. ‘cursor.execute’: This method is used to execute SQL queries.

4. ‘con.commit’: This method is used to commit the changes to the database.

5. ‘Mysql.connector.IntegrityError’: This exception is caught when there is a


violation of integrity constraints, such as trying to insert a duplicate primary
key.

6. ‘input’: This function is used to take user input from the console.

Database Table(s) used in the project –

contact_details

11
PROJECT CODE

import mysql.connector

# Create a connection to the MySQL server


conn = mysql.connector.connect(
host="localhost",
user="root",
password="mysql",
database="udayan"
)

cursor = conn.cursor()

# Create the table if it doesn't exist


create_table_query = '''
CREATE TABLE IF NOT EXISTS contacts (
name VARCHAR(255) PRIMARY KEY,
phone BIGINT
)
'''
cursor.execute(create_table_query)

def add_contact(name, phone):


try:
cursor.execute("INSERT INTO contacts VALUES (%s, %s)", (name,
phone))
conn.commit()
print("Contact added")
except mysql.connector.IntegrityError:
print("Contact with this name already exists")

def change_phone_number(name, new_phone):


cursor.execute("UPDATE contacts SET phone = %s WHERE name = %s",
(new_phone, name))
if cursor.rowcount > 0:
conn.commit()
print("Phone number changed")
else:
print("No contact found with this name")

12
def delete_contact(name):
cursor.execute("DELETE FROM contacts WHERE name = %s", (name,))
if cursor.rowcount > 0:
conn.commit()
print("Contact deleted")
else:
print("No contact found with this name")

def display_contacts():
cursor.execute("SELECT * FROM contacts")
rows = cursor.fetchall()
if rows:
for row in rows:
print(row[0], row[1])
else:
print("No contacts found")

def display_sorted_contacts():
cursor.execute("SELECT * FROM contacts ORDER BY name")
rows = cursor.fetchall()
if rows:
for row in rows:
print(row[0], row[1])
else:
print("No contacts found")

def check_contact(name):
cursor.execute("SELECT phone FROM contacts WHERE name = %s",
(name,))
row = cursor.fetchone()
if row:
print("Phone number:", row[0])
else:
print("No contact found with this name")

while True:
print("""
1. Add contact
2. Change the phone number of a contact
3. Delete a contact
4. Display all contacts
5. Display all contacts in sorted order

13
6. Check whether a contact exists
7. Exit
""")
choice = int(input("Enter a choice: "))

if choice == 1:
name = input("Enter a name of the friend: ")
phno = int(input("Enter the phone number of the friend: "))
add_contact(name, phno)
elif choice == 2:
name = input("Enter the contact name whose phone number to be changed:
")
phno = int(input("Enter the new phone number: "))
change_phone_number(name, phno)
elif choice == 3:
name = input("Enter the name of the contact to be deleted: ")
delete_contact(name)
elif choice == 4:
display_contacts()
elif choice == 5:
display_sorted_contacts()
elif choice == 6:
name = input("Enter the name to be searched: ")
check_contact(name)
elif choice == 7:
conn.close()
break
else:
print("Invalid option selected")

#code over

OUTPUT
14
 Main menu

 To add new contact

 To change the phone number of a contact

 To delete a contact

15
 To display all contacts

 To display all contacts in sorted order

 To check whether a contact exists

16
CONCLUSION
17
The project, “Phone Contact Management”
system is just one example of using technology for
a better cause. Phone contact management is not
an easy task as huge scale of data has to be
stored and processed.Data processing is a tiring
job.Humans alone cannot manage and process
such huge data.
Through this project, we developed a
better understanding of python and its modules .It
helped us to brush up certain concepts of python
which we learned in class 11 and 12.This project
gave a clear idea of real life applicability of python
and solve real life problems.

BIBLIOGRAPHY

18
Websites:

1.https://www.w3schools.com/python/python_intro.asp

2. https://www.python.org/about/gettingstarted/

3 https://www.learnpython.org/

4.https://stackoverflow.blog/2021/07/14/getting-started-with-python

Books:

1.Computer Science, Class XII, NCERT

2. Computer Science, Class XI, NCERT

3. All in one computer science, class 12, Arihant Publications

19

You might also like