You are on page 1of 23

CERTIFICATE

This is to certify that R.Jerolin Mary has successfully


completed Computer Science Project towards partial
completion of Practical examination of AISSCE 2023-
24 as prescribed by CBSE.

Internal Examiner External Examiner


_______________________________________________

TABLE OF CONTENT

1. What is Python?
2. Why Python?
3. What Can Python Do?
4. Interface Python with MySQL
5. Source Code
6. Output
7. Result
8. Bibliography
What Is Python?

Python is a popular programming language. It was


created by Guido van Rossum, and released in 1991.

It is used for:

 web development (server-side)


 software development
 mathematics
 system scripting.

Why Python?
 Python works on different platforms (Windows,
Mac, Linux, Raspberry Pi, etc).

 Python has a simple syntax similar to the English


language.

 Python has syntax that allows developers to write


programs with fewer lines than some other
programming languages.

 Python runs on an interpreter system, meaning that


code can be executed as soon as it is written. This
means that prototyping can be very quick.

 Python can be treated in a procedural way, an


object-oriented way or a functional way.

What Can Python Do?


 Python can be used on a server to create web
applications.

 Python can be used alongside software to create


workflows.

 Python can connect to database systems. It can also


read and modify files.

 Python can be used to handle big data and perform


complex mathematics.

 Python can be used for rapid prototyping, or for


production-ready software development.
Interface Python with MySQL

The interface between Python and MySQL allows


seamless communication and interaction between the
Python programming language and MySQL databases.

It enables Python developers to connect, retrieve,


manipulate, and manage data stored in MySQL
databases using Python scripts or applications.
some key applications:

1. Web Development:
 Dynamic Websites.

2. Web Development:
 Dynamic Websites
 Visualisation

3. Automation and Scripting:


 Task Automation
 Custom Scripting
4. Machine Learning and AI:
 Data Preparation
 Model Deployment

5. IoT and Embedded Systems:


 Data Storage
 Data Processing

6. Application Development:
 Custom Applications

7. E-commerce and Content Management:


 E-commerce Platforms
 Content Management Systems (CMS)

SOURCE CODE:
import mysql.connector as ms

import sys

mycon=
ms.connect(host="localhost",user="root",passwd="root",datab
ase="recipe")

if mycon.is_connected==False:

print("Error in Connecting")

cur=mycon.cursor()

print("=======RECIPE MANAGEMENT
SYSTEM=======")

print('''Choose a Number to Procceed

1. Add New Recipe

2. View Recipe

3. Delete Recipe

4. Update Recipe

5.Exit\n''')

inp=int(input("Enter Number: "))


#adding a new record into the table

if inp==1:

print("Adding a New Recipe to the List")

food=input("Enter Food Name: ")

ing=input("Enter Required Ingredients: ")

eq=input("Enter Required Equipments: ")

ins=input("Enter Instructions: ")

rat=int(input("Ratings from 1-5: "))

qry="insert into recipe values('{}','{}','{}','{}',


{})".format(food,ing,eq,ins,rat)

cur.execute(qry)

mycon.commit()

count=cur.rowcount

print(count,"Record is Added to the List")

print("Press Enter to Continue")

input()

#viewing records from the table


elif inp==2:

print('''1. View All Record

2. View Selected Record''')

view=int(input("Enter Number: "))

if view==1:

cur.execute("select* from recipe")

data=cur.fetchall()

for row in data:

print("------------------------------------------------------------","\n"

"FOOD:",row[0],'\n'

"INGREDIENTS:",row[1],'\n'

"EQUIPMENTS:",row[2],'\n'

"INSTRUCTIONS:",row[3],'\n'

"RATINGS:",row[4],"\n",

"------------------------------------------------------------")

print("Press Enter To Continue")

input()
elif view==2:

cur.execute("select* from recipe")

data=cur.fetchall()

avail=0

l=input("Enter Food: ")

for row in data:

if row[0]==l:

avail=1

print("------------------------------------------------------------","\n"

"FOOD:",row[0],'\n'

"INGREDIENTS:",row[1],'\n'

"EQUIPMENTS:",row[2],'\n'

"INSTRUCTIONS:",row[3],'\n'

"RATINGS:",row[4],"\n",

"------------------------------------------------------------")

else:

if avail==0:
print("record not found")

print("Press Enter To Continue")

input()

#deleting a record from the table

elif inp==3:

print("Deleting a Record")

cur.execute("select* from recipe")

data=cur.fetchall()

for row in data:

print("------------------------------------------------------------","\n"

"FOOD:",row[0],'\n'

"INGREDIENTS:",row[1],'\n'

"EQUIPMENTS:",row[2],'\n'

"INSTRUCTIONS:",row[3],'\n'

"RATINGS:",row[4],"\n",

"------------------------------------------------------------")

fid=input("Enter Food: ").lower()


delete=0

for row in data:

if row[0]==fid:

delete=1

qry="delete from recipe where


food_name='{}'".format(fid)

cur.execute(qry)

mycon.commit()

print()

if delete==1:

print("Record Deleted Successfully")

else:

print("Record Not Available")

print()

cur.execute("select* from recipe")

data=cur.fetchall()

for row in data:

print("-----------------------------------------------------------","\n"
"FOOD:",row[0],'\n'

"INGREDIENTS:",row[1],'\n'

"EQUIPMENTS:",row[2],'\n'

"INSTRUCTIONS:",row[3],'\n'

"RATINGS:",row[4],"\n",

"-----------------------------------------------------------")

print("Press Enter To Continue")

input()

#updating a record from the table

elif inp==4:

print("Updating a Record")

fid =(input("Enter Food: "))

qry = "Select * from recipe where food_name = '{}' order


by food_name".format(fid)

cur.execute(qry)

row = cur.fetchone()

count = cur.rowcount
print(count," record is searched successfully.")

print("-----------------------------------------------------------","\
n"

"FOOD:",row[0],'\n'

"INGREDIENTS:",row[1],'\n'

"EQUIPMENTS:",row[2],'\n'

"INSTRUCTIONS:",row[3],'\n'

"RATINGS:",row[4],"\n",

"-----------------------------------------------------------")

food=input("Enter Food(new) or .(old): ")

ing=input("Enter Ingredients(new) or .(old): ")

eq=input("Enter Equipments(new) or .(old): ")

ins=input("Enter Instructions(new) or .(old): ")

if food == '.':

food = row[0]

if ing == '.':

ing = row[1]

if eq == '.':

eq = row[2]
if ins == '.':

ins = row[3]

qry="update recipe set food_name = '{}', ingredients = '{}',


equipments = '{}',\

instructions = '{}'where food_name =


'{}'".format(food,ing,eq,ins,fid)

cur.execute(qry)

mycon.commit()

count = cur.rowcount

print(count," record is updated successfully.")

print("Press Enter to continue.")

input()

#exit database

elif inp==5:

mycon.close()

print("Terminating Program")

sys.exit(0)
else:

print("Wrong Input Try Again")

print("Press Enter to continue.")

input()

OUTPUT:

1. Adding a Record
2. A) Viewing All Record

2. B) Viewing a Selected Record


3. Deleting a Record
4. Updating a Record

5. Exit

RESULT:

The Above Program Has Been Executed Successfully.


BIBILIOGRAPHY:

 https://www.google.com
 https://www.w3schools.com
 https://www.python.org
 https://www.wikipedia.org
 http://www.ncert.nic.in
_______________________________________________

ACKNOWLEDGEMENT

I wish to express my deep gratitude and sincere thanks


to all

my teachers for encouragement and the management for


providing all facilities to successfully complete the
project work.

I extend my sincere thanks to my Physics teacher Mrs.


Gokila, whose valuable guidance helped to successfully
complete the project.

I extend my gratitude to my parents and classmates for


their valuable support and time.

You might also like