0% found this document useful (0 votes)
3 views

Out Put Code

The document contains a Python implementation of a simple chatbot class that provides random responses to user input. The chatbot greets the user and continues the conversation until the user types 'exit'. It includes various predefined responses to engage with the user.

Uploaded by

mindada.mendis
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Out Put Code

The document contains a Python implementation of a simple chatbot class that provides random responses to user input. The chatbot greets the user and continues the conversation until the user types 'exit'. It includes various predefined responses to engage with the user.

Uploaded by

mindada.mendis
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import random

class SimpleChatbot:
def __init__(self):
self.responses = [
"Hello! How can I assist you today?",
"I'm here to chat! What's on your mind?",
"How are you doing today?",
"Tell me more about that!",
"That's interesting! Can you elaborate?",
"I'm not sure I understand. Can you explain?",
"What else would you like to talk about?"
]

def get_response(self):
return random.choice(self.responses)

def chat():
bot = SimpleChatbot()
print("Chatbot: Hi! I'm your chatbot. Type 'exit' to end the chat.")
while True:
user_input = input("You: ")
if user_input.lower() == 'exit':
print("Chatbot: Goodbye!")
break
response = bot.get_response()
print(f"Chatbot: {response}")

if __name__ == "__main__":
chat()

You might also like