Lesson 7.3: Silly Chatbots

Today’s Goals

  • Use if/elif/else statements to build a simple chatbot
  • Practice responding to user input
  • Explore creativity in interactive programs

Warm-Up Question

  • If you had a personal robot, what would you want it to say to you?

Chatbot Basics

name = input("What is your name? ")
print("Hello,", name, "I am a chatbot!")

Adding Choices

user_input = input("How are you today? ")

if user_input == "good":
    print("I’m glad to hear that!")
elif user_input == "bad":
    print("I’m sorry. I hope things get better.")
else:
    print("Interesting! Tell me more.")

Class Practice

  • Add more possible responses to your chatbot
  • Try making it respond to at least 3 different moods

Student Challenge

  • Create a chatbot that asks at least 3 different questions
  • Give at least 2 possible responses for each question

Wrap-Up

  • Chatbots use conditionals to interact with users
  • Next time: We’ll debug and improve our chatbots