Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Python MicroP

VBGB GHNYJNN HGH

Uploaded by

pratiksingh6005
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python MicroP

VBGB GHNYJNN HGH

Uploaded by

pratiksingh6005
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Rule-Based Chatbot using Python

Project Title:
Rule-Based Chatbot using Python

Introduction
In the modern era of automation and artificial intelligence, chatbots have
emerged as powerful tools for simulating human-like conversations. A
chatbot is a software program designed to interact with users through text
or voice, providing automated responses to predefined queries. They are
widely used in customer service, virtual assistants, websites, and various
applications.

This micro project aims to develop a simple rule-based chatbot using


Python. Unlike AI-based bots, rule-based chatbots operate using
predefined patterns and responses, making them easy to implement for
beginners. The chatbot built in this project responds to basic greetings,
time/date queries, and common conversational phrases. It helps students
understand how basic logic, control flow, and string handling in Python
can be used to create interactive applications.

This project also encourages students to explore user interaction and lays
the foundation for more advanced topics such as Natural Language
Processing (NLP) and Machine Learning (ML) in the future.

Objective:
To create a simple rule-based chatbot using Python that can interact with the user and
respond to basic queries.

Tools & Technologies:


 Language: Python

 IDE: VS Code / PyCharm / IDLE

 Modules: None required (basic Python only)

Working Principle:
The chatbot uses if-elif statements or dictionary-based matching to answer frequently
asked questions like greetings, name, weather, time, etc.

Python Code:
python
CopyEdit
import datetime

def chatbot():
print("🤖 ChatBot: Hello! I'm PyBot. Type 'exit' to end the chat.")
while True:
user_input = input("👤 You: ").lower()

if user_input in ["hi", "hello", "hey"]:


print("🤖 ChatBot: Hello! How can I help you?")
elif user_input in ["what is your name?", "your name", "who are
you"]:
print("🤖 ChatBot: I am PyBot, your friendly chatbot.")
elif "time" in user_input:
current_time = datetime.datetime.now().strftime("%I:%M %p")
print(f"🕒 ChatBot: The current time is {current_time}")
elif "date" in user_input:
today = datetime.date.today()
print(f"📅 ChatBot: Today's date is {today.strftime('%B %d,
%Y')}")
elif "how are you" in user_input:
print("🤖 ChatBot: I'm just a bot, but I'm functioning as
expected!")
elif "bye" in user_input or user_input == "exit":
print("👋 ChatBot: Goodbye! Have a great day.")
break
else:
print("🤖 ChatBot: Sorry, I didn't understand that.")

# Run the chatbot


chatbot()

Output:

You might also like