From 11d291da19b1d7872f748723d0199da0a90464a0 Mon Sep 17 00:00:00 2001 From: yaswanthkumarch Date: Sun, 24 Aug 2025 22:14:02 +0530 Subject: [PATCH 1/2] Added Chat Simulator project --- .../yaswanthkumarch/chat_simulator/README.md | 38 +++++++++++++++ .../chat_simulator/chat_simulator.py | 47 +++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 week1_projects/yaswanthkumarch/chat_simulator/README.md create mode 100644 week1_projects/yaswanthkumarch/chat_simulator/chat_simulator.py diff --git a/week1_projects/yaswanthkumarch/chat_simulator/README.md b/week1_projects/yaswanthkumarch/chat_simulator/README.md new file mode 100644 index 0000000..5266c5c --- /dev/null +++ b/week1_projects/yaswanthkumarch/chat_simulator/README.md @@ -0,0 +1,38 @@ +# Chat Simulator Project + +## What the project does +This is a simple command-line chatbot built in Python. It responds to basic greetings, tells the time and date, and can exit the chat on command. + +## How to run +1. Run the Python script: + + + +git checkout -b yaswanth-chat-simulator + + + +git add week1_projects/yaswanthkumarch/chat_simulator/ +git commit -m "Yaswanth – Chat Simulator Project" +git push origin yaswanth-chat-simulator + + + +This pull request adds a simple command-line Chat Simulator built in Python. + +Features include: +- Greeting the user +- Responding to basic questions such as "What's your name?" and "What's the time?" +- Responding differently based on keywords in user input +- Allowing the user to exit the chat by typing keywords like "bye" or "exit" +- Keeping a conversation history stored in a list + +The project demonstrates the use of Python syntax, conditional statements, loops, and basic CLI interaction. + +Looking forward to feedback and suggestions. Thank you! + + + + + +[Yaswanth] – Chat Simulator Project diff --git a/week1_projects/yaswanthkumarch/chat_simulator/chat_simulator.py b/week1_projects/yaswanthkumarch/chat_simulator/chat_simulator.py new file mode 100644 index 0000000..14daf91 --- /dev/null +++ b/week1_projects/yaswanthkumarch/chat_simulator/chat_simulator.py @@ -0,0 +1,47 @@ +import datetime + +def greet_user(): + print("Hello! I am ChatSim, your friendly chatbot.") + print("You can ask me basic questions or type 'bye' or 'exit' to quit.") + +def get_response(user_input): + user_input = user_input.lower() + + if "hello" in user_input or "hi" in user_input: + return "Hi there! How can I help you today?" + elif "your name" in user_input: + return "I am ChatSim, your command-line chatbot." + elif "time" in user_input: + now = datetime.datetime.now().strftime("%H:%M:%S") + return f"The current time is {now}." + elif "date" in user_input: + today = datetime.datetime.now().strftime("%Y-%m-%d") + return f"Today's date is {today}." + elif user_input in ["bye", "exit", "quit"]: + return "exit" + else: + return "Sorry, I didn't understand that. Can you ask something else?" + +def main(): + greet_user() + conversation_history = [] + + while True: + user_input = input("You: ") + conversation_history.append(f"You: {user_input}") + + response = get_response(user_input) + if response == "exit": + print("ChatSim: Goodbye! Have a great day!") + break + else: + print(f"ChatSim: {response}") + conversation_history.append(f"ChatSim: {response}") + + # Optional: Save conversation history to a text file + with open("chat_history.txt", "w") as f: + for line in conversation_history: + f.write(line + "\n") + +if __name__ == "__main__": + main() From 6349e4a950abfc1d291ead3b47b8b737de0d309a Mon Sep 17 00:00:00 2001 From: yaswanthkumarch Date: Sun, 24 Aug 2025 22:17:41 +0530 Subject: [PATCH 2/2] Added Chat Simulator project --- week1_projects/yaswanthkumarch/chat_simulator/README.md | 4 ---- .../yaswanthkumarch/chat_simulator/chat_simulator.py | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/week1_projects/yaswanthkumarch/chat_simulator/README.md b/week1_projects/yaswanthkumarch/chat_simulator/README.md index 5266c5c..79e8825 100644 --- a/week1_projects/yaswanthkumarch/chat_simulator/README.md +++ b/week1_projects/yaswanthkumarch/chat_simulator/README.md @@ -31,8 +31,4 @@ The project demonstrates the use of Python syntax, conditional statements, loops Looking forward to feedback and suggestions. Thank you! - - - - [Yaswanth] – Chat Simulator Project diff --git a/week1_projects/yaswanthkumarch/chat_simulator/chat_simulator.py b/week1_projects/yaswanthkumarch/chat_simulator/chat_simulator.py index 14daf91..b83ab89 100644 --- a/week1_projects/yaswanthkumarch/chat_simulator/chat_simulator.py +++ b/week1_projects/yaswanthkumarch/chat_simulator/chat_simulator.py @@ -43,5 +43,6 @@ def main(): for line in conversation_history: f.write(line + "\n") + if __name__ == "__main__": main()