Tech Jobs Hub
21.5K subscribers
803 photos
13 videos
26 files
998 links
Jobs is your go-to channel for the latest job opportunities in Data Science, Programming, Web Development, Design, and more.

We bring you handpicked job listings, career tips, and resources to help you learn, grow, and land your dream role.
Download Telegram
Q: How can you simulate basic human-like behavior in a simple program using Python?

Imagine a chatbot that responds to user inputs with random, yet plausible, replies—mimicking how people react in conversations. For beginners, this involves using random module to generate responses based on keywords. Here’s a simple example:

import random

responses = {
"hello": ["Hi there!", "Hello!", "Hey!"],
"how are you": ["I'm good, thanks!", "Doing well!", "Pretty great!"],
"bye": ["Goodbye!", "See you later!", "Bye!"]
}

def chatbot():
while True:
user_input = input("You: ").lower()
if user_input == "quit":
print("Bot: Goodbye!")
break
for key in responses:
if key in user_input:
print(f"Bot: {random.choice(responses[key])}")
break
else:
print("Bot: I don't understand. Can you rephrase?")

chatbot()

This simulates basic human-like interaction by matching keywords and responding randomly from predefined lists. It’s a foundational step toward more advanced behavioral simulation.

#Python #BeginnerProgramming #Chatbot #HumanBehaviorSimulation #CodeExample

By: @DataScienceQ 🚀