This commit is contained in:
Page Asgardius 2024-04-13 11:03:33 -07:00
parent 71bc7859b4
commit 55d6c8ad8d

35
frank.py Normal file
View file

@ -0,0 +1,35 @@
#Let's Create a Simple Chatbot in Python
#define a greet function
def greet(bot_name, birth_year):
#print the question answers
print(f"Chatbot: Hello, I am {bot_name}. I was created in {birth_year}.")
print("Chatbot: How can I help you today?")
#Use another Function respond
def respond(user_input):
#use conditional statements
if user_input.lower() == "hi" or user_input.lower() == "hello":
return "Hello there! How can I help you today?"
elif user_input.lower() == "bye":
return "Goodbye! Have a great day."
elif user_input.lower() == "what is your good name?":
return "My name is Chatbot."
elif user_input.lower() == "what is your birth year?":
return "I was created in 2021."
elif user_input.lower() == "what can you do?":
return "I can answer your questions, have a conversation with you, and perform basic tasks."
elif "weather" in user_input.lower():
return "I am not able to check the weather at the moment, sorry."
else:
return "I'm sorry, I don't understand what you're trying to say. Could you please rephrase that?"
bot_name = "Chatbot"
birth_year = 2021
greet(bot_name, birth_year)
while True:
user_input = input("You: ")
response = respond(user_input)
print(f"Chatbot: {response}")
if user_input.lower() == "bye":
break