KENDRIYA VIDYALAYA
AMBARNATH
2025-26
PRACTICAL PROJECT
COMPUTER
Science
Simple Chatbot
ACKNOWLEDGEMENT
I, Swati Singh of class XII B, would like to express my heartfelt
gratitude to all those who supported me in completing this
computer science project
First and foremost, I am immensely grateful to Kshma Raut
Mam, my teacher, for her invaluable guidance, encouragement,
and mentorship throughout the project. Her expertise and
constructive feedback have been instrumental in shaping my
understanding and the outcome of this work.
I would also like to thank my school for providing the resources
and environment necessary for conducting this project. Lastly, I
am deeply appreciative of each other’s efforts and teamwork
that allowed us to complete this project.
Thank you all for making this learning experience truly enriching.
Teacher's Student's
Signature Signature
CERTIFICATE
I would like to express my sincere gratitude to my
Computer Science teacher, Kshama Raut, for her
valuable guidance, constant encouragement, and for
providing me with the necessary support to complete
this project on "Simple Chatbot". Her mentorship was
instrumental in the successful completion of this
project.
I am also thankful to our respected Principal, Shri
Mukesh Kumar Sir, for providing me with the
opportunity and the necessary facilities to undertake
this project.
My heartfelt gratitude also goes to my parents and
friends for their unwavering support, motivation, and
help throughout the duration of this project.
Finally, I would like to thank everyone who directly or
indirectly helped me in the successful completion of this
project.
11.12.2025
Date: _________________________
INDEX
Acknowledgment
Certificate
Introduction
Objective
Software
Required
Coding
Output
Bibliography
INTRODUCTION
Python is a high-level, versatile, and interpreted
programming language created by Guido van
Rossum and first released in 1991. It is known for
its simplicity and readability, making it an
excellent choice for beginners and professionals
alike. Python supports multiple programming
paradigms, including procedural, object-oriented,
and functional programming.
Python
IDLE (Integrated Development and Learning
Environment) is the default editor and development
environment that comes bundled with Python. It
provides a simple interface for writing, editing, and
executing Python code. Designed for beginners,
IDLE features a Python shell, syntax highlighting,
auto-completion, and basic debugging tools. Its
lightweight and user-friendly design make it an
ideal starting point for learning Python
programming.
IDLE
MySQL is one of the most popular open-source
Relational Database Management Systems (RDBMS)
used worldwide. It uses Structured Query Language
(SQL) to store, retrieve, and manage data efficiently
in tabular format with rows and columns. MySQL is
known for its speed, reliability, and ease of use,
making it a top choice for web applications and
software development. In Class 12 Computer Science,
we study MySQL to understand how to create
databases, execute queries, and connect Python
programs to backend storage for building dynamic
applications.
My SQL
S I M P L E C H AT B OT S Y S T E M
The "Simple Chatbot System" is a Python-based
application designed to interact with users through a
Graphical User Interface (GUI). It simulates a conversation
by matching user queries with predefined questions
stored in a MySQL database.
In today's digital world, chatbots are used everywhere for
customer support and information retrieval. This project
demonstrates how Python can be integrated with a
backend database (MySQL) to create a responsive and
intelligent application. The system uses the Tkinter library
for the interface and [Link] for database
operations.
OBJECTIVE
To investigate on the
PROJECT :– Simple ChatBot
The primary goal of the "Simple Chatbot System" project is to bridge the gap
between theoretical knowledge and practical application. The specific objectives are
as follows:
1. To Apply Concepts of Python-MySQL Connectivity:
The core objective is to practically implement the Python-MySQL Connectivity unit
from the Class 12 syllabus. This involves establishing a secure connection between
the Python front-end and the MySQL back-end using the [Link] library,
managing database cursors, and handling real-time data exchange.
2. To Execute SQL Queries via Python:
This project aims to demonstrate how SQL commands can be triggered
programmatically rather than manually via the command line. It focuses on using
DDL (Data Definition Language) to create database structures and DML (Data
Manipulation Language) commands like INSERT to store predefined QA pairs and
SELECT to fetch matching answers based on user input efficiently.
3. To Create a User-Friendly GUI Application:
Moving beyond text-based (CLI) programs, this project seeks to develop an
interactive Graphical User Interface (GUI) using the Tkinter library. The objective is to
design a clean, intuitive window with widgets like Entry boxes, Buttons, and
Scrollbars, making the application accessible and easy to use for non-technical users.
4. To Demonstrate a Basic Query-Response System:
The final objective is to simulate a simplified version of Artificial Intelligence. By
matching user inputs with stored database records, the system demonstrates the
fundamental logic behind retrieval-based chatbots, showing how software can
process text inputs and provide relevant, context-aware responses.
SOFTWARE
REREQUIRED
My SQL
Python
IDLE
CODES
Database Setup
([Link])
import [Link]
db = [Link](
host="localhost",
user="root",
passwd="YOUR_PASSWORD"
)
cursor = [Link]()
[Link]("CREATE DATABASE IF NOT EXISTS chat_db")
[Link]("USE chat_db")
[Link]("DROP TABLE IF EXISTS qa")
[Link]("CREATE TABLE qa (question VARCHAR(200), answer
VARCHAR(200))")
data = [
("hello", "Hi! How can I help?"),
("how are you", "I am great, thanks!"),
("what is your name", "I am a simple bot."),
("bye", "Goodbye! See you soon.")
]
for q, a in data:
[Link]("INSERT INTO qa VALUES (%s, %s)", (q, a))
[Link]()
print("Database and Questions Created Successfully!")
Main Application Code
([Link])
import [Link]
from tkinter import *
def get_reply(msg):
db = [Link](
host="localhost",
user="root",
passwd="YOUR_PASSWORD", # Put your password here!
database="chat_db"
)
cursor = [Link]()
[Link]("SELECT answer FROM qa WHERE question
= %s", ([Link](),))
result = [Link]()
[Link]()
if result:
return result[0]
else:
return "Sorry, I don't know that."
def send():
msg = [Link]()
([Link])
[Link](state=NORMAL) # Unlock chat
[Link](END, "You: " + msg + "\n")
reply = get_reply(msg) # Ask MySQL
[Link](END, "Bot: " + reply + "\n\n")
[Link](state=DISABLED) # Lock chat
[Link](0, END) # Clear box
# GUI Setup (Looks exactly the same)
root = Tk()
[Link]("MySQL Chatbot")
# Text Area
chat = Text(root, bg="white", width=50, height=15, font=
("Arial", 12))
[Link](state=DISABLED)
[Link](row=0, column=0, columnspan=2)
# Input Box
entry = Entry(root, width=40, font=("Arial", 12))
[Link](row=1, column=0)
# Button
btn = Button(root, text="Send", command=send)
[Link](row=1, column=1)
OUTPUT
BIBLIOGRAPHY
Materials used to complete
this project are -
[Link]/3/library/[Link]
[Link]
[Link]
XII TEXTBOOK - SUMITA ARORA