PART- A
1. Write a simple Python program using if-else statements to simulate a chat with the user (e.g., User:
"Hi", AI: "Hello! How are you?"; User: "Bye", AI: "See you!").
# PART-A
## 1. Python Program to Simulate a Simple Chat Using If-Else Statements
def simple_chatbot():
print("Bot: Hello! I'm a simple chatbot. (Type 'bye' or 'exit' to quit)\n")
while True:
# Get input and normalize it to lowercase
user_input = input("You: ").strip().lower()
# Check user intent using if-elif-else statements
if user_input in ["bye", "exit", "quit"]:
print("Bot: Goodbye! Have a great day!")
break
elif user_input in ["hello", "hi", "hey"]:
print("Bot: Hi there! How can I help you today?")
elif "how are you" in user_input:
print("Bot: I'm just code, but I'm running smoothly! How are you?")
elif "your name" in user_input:
print("Bot: I'm PyBot, a simple rule-based assistant.")
elif "good" in user_input or "fine" in user_input:
print("Bot: Glad to hear that!")
elif "help" in user_input:
print("Bot: You can say hi, ask my name, ask how I'm doing, or type 'bye' to leave.")
elif user_input == "":
print("Bot: You didn't say anything!")
else:
print("Bot: I'm not sure how to respond to that yet. Try asking something else!")
if __name__ == "__main__":
simple_chatbot()