Beginner — Day 2

Conditional Statements

Day Schedule
Online
TimeActivity
10:00input() and int()
Getting user input; converting strings to numbers; demo TypeError
10:20If / Elif / Else
Comparison operators; demo changing score and re-running
10:40Nested If-Else
Build a decision tree; intro to Boredom Buster Bot
11:00Break
11:10Breakout Groups
Project: Boredom Buster Bot
12:20Reminders
In-Person
TimeActivity
8:00Warm-Up
Review Day 1: quick variable Q&A, fix any setup issues
8:20input() and int()
Getting user input; converting strings to numbers; demo TypeError
8:50If / Elif / Else
Comparison operators; demo changing score and re-running
9:20Nested If-Else
Build a decision tree; intro to Boredom Buster Bot
9:40Break
9:50Breakout Groups
Project: Boredom Buster Bot
11:00Break
11:10Extra Activity
Trivia Quiz: students write their own question-and-answer pattern
11:50Open Coding
Catch up or extend the bot with more moods
12:20Reminders
Learning Objectives
  1. Use input() to get text from the user
  2. Convert a string to an integer with int()
  3. Create a single if / elif / else statement
  4. Create a nested if-else statement
  5. Know the comparison operators: <=, >=, ==, !=
# INSTRUCTOR — Day 2: Conditional Statements (Beginner)
# -----------------------------------------------
# TEACH: Programs make decisions with if/elif/else.
# Python checks conditions top to bottom and runs the FIRST match.
# Once a block runs, the rest are skipped.
# Demo: change the score value and re-run to show different branches.

# TEACH: Introduce input() alone BEFORE combining it with int().
# "input() pauses the program and waits for the user to type something. It always returns a string."
# Demo this first — run it and show type():
#   raw = input("Enter your score: ")
#   print(type(raw))          # → <class 'str'> even when they type 90
# Ask: "What goes wrong if we compare a string to 90 with >= ?" (run it and show the TypeError)
#
# TEACH: Now introduce int() as the fix.
# "int() converts a string that looks like a number into an actual number."
#   int("90") → 90
#   int("hello") → ValueError  (demo this error so students know it exists)
# Now combine them:
score = int(input("Enter your test score: "))

if score >= 90:
    print("A — great work!")
elif score >= 80:
    print("B — good job.")
elif score >= 70:
    print("C — keep going.")
else:
    # TEACH: else has no condition — it's the catch-all for everything else
    print("Keep practicing — you'll get there!")

# TEACH: comparison operators
# ==   equal to           (NOT assignment — that's =)
# !=   not equal to
# >    greater than
# <    less than
# >=   greater than or equal to
# <=   less than or equal to

# COMMON MISTAKE: students use = instead of == in conditions
# Show this error: if score = 90:  → SyntaxError

# TEACH: ask students what happens if score is exactly 80. Which branch runs? Why?
# INSTRUCTOR — Day 2: Project: Boredom Buster Bot (Beginner)
# -----------------------------------------------
# TEACH: Nested if-else lets different answers lead to different outcomes.
# Key concept: user input with input() always returns a string.
# The == check compares the input string to the expected string exactly.
# Demo: type "Bored" (capital B) and show it doesn't match "bored".

print("Hey! I'm your Boredom Buster Bot.")
mood = input("How are you feeling? (bored / tired / hungry): ")

if mood == "bored":
    # TEACH: this is a nested if — an if inside another if
    activity = input("Do you want something active or chill? ")
    if activity == "active":
        print("Go outside and challenge someone to a race!")
    else:
        print("Watch a funny YouTube video.")

elif mood == "tired":
    print("Take a 20-minute nap. You'll feel better!")

elif mood == "hungry":
    print("Go make a snack. You've earned it!")

else:
    # TEACH: the else catches any input that doesn't match — important for robustness
    print("I'm not sure what to do with that. Try again!")

# TEACH: students should replace the print strings with their own suggestions.
# Challenge: add one more mood with a nested follow-up question.
# Example below — walk through it with the class before they try on their own.

# elif mood == "anxious":
#     help_type = input("Want to talk about it or distract yourself? ")
#     if help_type == "talk":
#         print("Write down three things you're grateful for right now.")
#     else:
#         print("Put on your favorite song and dance for one minute.")
# INSTRUCTOR — Day 2: Extra Activity: Trivia Quiz (Beginner)
# -----------------------------------------------
# TEACH: Students read the existing question pattern and repeat it.
# The goal is pattern recognition — not inventing from scratch.
# Walk through Question 1 before releasing students to write Questions 2 and 3.

# Question 1 (complete — show students this pattern)
answer = input("What is 7 x 8? ")
if answer == "56":
    print("Correct!")
else:
    print("Not quite. The answer is 56.")

# Question 2 (student fills this in)
answer = input("What is the capital of France? ")
if answer == "Paris":
    print("Correct!")
else:
    print("Not quite. The answer is Paris.")

# Question 3 (student writes from scratch)
answer = input("What planet is closest to the sun? ")
if answer == "Mercury":
    print("Correct!")
else:
    print("Not quite. The answer is Mercury.")

# TEACH: challenge — add a score counter that increases by 1 for each correct answer
# and prints the total at the end. This foreshadows variables persisting across code.

# Challenge extension:
score = 0
# (score += 1 in each correct branch, then print("Score: " + str(score)) at the end)