๐ฏ Project Objective
To build a Python Chatbot / Assistant capable of interacting with users via text input. This project demonstrates:
- Handling user input
- Conditional logic and string processing
- Integrating APIs for real-world functionality
- Creating an intelligent assistant for automation tasks
Project: Python Chatbot / Assistant
Project Description
The Chatbot/Assistant can:
- Respond to greetings and common questions
- Perform basic calculations
- Fetch data like date, time, or weather
- Provide simple automation for tasks
Use Cases:
- Personal assistant for reminders or information
- FAQ bot for websites
- Learning AI logic with Python
Python Example Code โ Basic Text Chatbot
import datetime
def chatbot_response(user_input):
user_input = user_input.lower()
if "hello" in user_input or "hi" in user_input:
return "Hello! How can I help you today?"
elif "time" in user_input:
now = datetime.datetime.now()
return f"The current time is {now.strftime('%H:%M:%S')}"
elif "date" in user_input:
today = datetime.date.today()
return f"Today's date is {today}"
elif "calculate" in user_input:
try:
expression = user_input.replace("calculate", "").strip()
result = eval(expression)
return f"The result is {result}"
except:
return "Sorry, I couldn't calculate that."
elif "bye" in user_input or "exit" in user_input:
return "Goodbye! Have a nice day."
else:
return "I'm not sure about that. Can you ask something else?"
# Chat loop
print("Welcome to Python Chatbot! Type 'exit' to quit.\n")
while True:
user_input = input("You: ")
response = chatbot_response(user_input)
print("Bot:", response)
if "Goodbye" in response:
break
โ Output:
You: hello
Bot: Hello! How can I help you today?
You: calculate 5 + 7
Bot: The result is 12
You: time
Bot: The current time is 14:30:15
You: exit
Bot: Goodbye! Have a nice day.
โ Key Features
- Interactive conversation with user
- Handles basic queries, calculations, and date/time
- Extensible to real-world tasks and automation
- Can be upgraded to GUI or voice-based assistant

Leave a Reply