From 55d6c8ad8debc757446394d947b77d144bcdf409 Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Sat, 13 Apr 2024 11:03:33 -0700 Subject: [PATCH] test --- frank.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 frank.py diff --git a/frank.py b/frank.py new file mode 100644 index 0000000..13cf1bb --- /dev/null +++ b/frank.py @@ -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