Python Varshini
Python Varshini
Synopsis
About Python:
About MySQL:
o Add new contacts (with mobile number, name, address, and email).
o Search/view contacts based on various criteria.
o Delete contacts by name.
SYNOPSIS
1. Readability:
Python emphasizes code readability and a clean syntax. The language is designed to be
easily readable and requires fewer lines of code compared to languages like C++ or Java.
2. Interpreted Language:
Python is an interpreted language, meaning that the Python code is executed line by line,
and it does not need to be compiled into machine code before running. This makes
development and debugging faster.
3. Versatility:
Python is a versatile language with a large standard library and a vast ecosystem of third-
party libraries and frameworks. This makes it suitable for a wide range of applications,
from web development (Django, Flask) to scientific computing (NumPy, SciPy) and
machine learning (TensorFlow, PyTorch).
4. Object-Oriented:
5. Dynamic Typing:
Python is dynamically typed, meaning that you don't need to specify the data type of a
variable explicitly. This allows for more flexibility but requires careful attention to
variable types during runtime.
6. Large Community and Support:
Python has a large and active community of developers. This community contributes to
the language's growth, provides support through forums and documentation, and creates a
wealth of open-source libraries and tools.
7. Cross-Platform:
Python is a cross-platform language, meaning that Python code can run on various
operating systems without modification. This cross-platform compatibility contributes to
its widespread adoption.
9. Community-driven Development:
MySQL is a relational database, which means it organizes data into tables with rows and
columns. It follows the principles of the relational model, facilitating the management
and retrieval of structured data.
2. Open Source:
MySQL is an open-source software, which means that its source code is freely available
to the public. This encourages collaboration and allows developers to modify the code to
suit their specific needs.
3. Ease of Use:
MySQL is known for its ease of use and straightforward setup process. It provides a
command-line interface (CLI) as well as graphical user interfaces (GUIs) like MySQL
Workbench for easier management of databases.
4. Cross-Platform Compatibility:
5. Scalability:
MySQL is scalable and can handle both small-scale and large-scale database applications.
It supports various storage engines, allowing developers to choose the one that best fits
their specific requirements.
6. ACID Compliance:
7. High Performance:
MySQL is known for its high performance, making it suitable for applications with
demanding data processing needs. It includes features such as caching, indexing, and
optimized algorithms to enhance performance.
MySQL has a large and active community of developers, users, and contributors. This
community provides support through forums, documentation, and contributions to the
improvement of the MySQL ecosystem.
9. Security:
MySQL supports replication, allowing data to be copied to multiple servers for backup or
load balancing. This enhances data availability and provides a level of fault tolerance.
MySQL is actively developed and receives regular updates to introduce new features,
improve performance, and address security concerns.
SYSTEM REQUIREMENTS
Recommended software’s:
MySQL
python
SOURCE
CODE
import mysql.connector as cd
cont = tuple(L)
sql = "INSERT INTO contact_book (mobile_no, name, address, email) VALUES (%s,
%s, %s, %s)"
mycursor.execute(sql, cont)
mydb.commit()
print("Contact added successfully!\n")
if ch == 1:
s = input("Enter Mobile Number: ")
rl = (s,)
sql = "SELECT * FROM contact_book WHERE mobile_no = %s"
mycursor.execute(sql, rl)
elif ch == 2:
nm = input("Enter Name: ")
sql = "SELECT * FROM contact_book WHERE name = %s"
mycursor.execute(sql, (nm,))
elif ch == 3:
s = input("Enter Address: ")
sql = "SELECT * FROM contact_book WHERE address = %s"
mycursor.execute(sql, (s,))
elif ch == 4:
s = input("Enter Email: ")
sql = "SELECT * FROM contact_book WHERE email = %s"
mycursor.execute(sql, (s,))
elif ch == 5:
sql = "SELECT * FROM contact_book"
mycursor.execute(sql)
res = mycursor.fetchall()
if res:
print("Contact details are as follows: (mobile_no, name, address, email)")
for x in res:
print(x)
else:
print("No contact found.")
# Function to delete a contact
def del_contact():
name = input("Enter the name of the contact to be deleted: ")
sql = "DELETE FROM contact_book WHERE name = %s"
mycursor.execute(sql, (name,))
mydb.commit()
print(f"Contact '{name}' deleted successfully!\n")
try:
userInput = int(input("Please select an option: "))
except ValueError:
print("Invalid input! Please enter a number.")
continue
if userInput == 1:
add_contact()
elif userInput == 2:
view_contact()
elif userInput == 3:
del_contact()
elif userInput == 4:
print("Exiting the application.")
break
else:
print("Invalid option! Please choose a valid option.")
www.Github.com
www.w3schools.com
www.Stackoverflow.com
www.freeCodeCamp.com
www.Geeksforgeeks.com