0% found this document useful (0 votes)
11 views2 pages

Print

The document outlines a simple chatbot program that interacts with users through predefined responses. It can respond to specific inputs related to greetings, assistance with math homework, and general inquiries about its identity. The chatbot ends the conversation when the user types 'bye' or expresses gratitude for help.

Uploaded by

RUDRAKSH GUPTA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Print

The document outlines a simple chatbot program that interacts with users through predefined responses. It can respond to specific inputs related to greetings, assistance with math homework, and general inquiries about its identity. The chatbot ends the conversation when the user types 'bye' or expresses gratitude for help.

Uploaded by

RUDRAKSH GUPTA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

print("Hello! I'm a simple chatbot.

Type 'bye' to end the chat ")

while True:
user_input = input("You: ").lower()

if user_input == "hlo":
print("Bot: Hi, what's up!")
elif user_input == "nice what about you?":
print("Bot: Good!")
elif user_input == "what's your name?":
print("Bot: I'm a Python chatbot. Your name please?")
elif user_input == "yashika gupta. can i ask a small help from u please?":
print("Bot: Yes for sure. What help do you need?")
elif user_input == "i need small help in maths holiday homework":
print("Bot: Sure! Please tell me what help you need in maths.")
elif user_input == "i am having some problems in solving questions of
adding. will u be able to help me?":
print("Bot: Yes for sure! Please write 2 numbers you want me to add.")

try:
num1 = float(input("Bot: Enter the first number: "))
num2 = float(input("Bot: Enter the second number: "))
total = num1 + num2
print("Bot: Here is your answer:", total)
except ValueError:
print("Bot: Please enter valid numbers.")
elif user_input == "thankx for helping me":
print("Bot: You're welcome! But I need to go, my battery is low.")
elif user_input == "bye":
print("Bot: Bye! Take care.")
break
else:
print("Bot: I'm not able to understand. Can you try saying that a different
way?")

You might also like