Skip to main content

Stage 1: Wake It Up

Course progressStage 1 of 10
~25 min
Build

an assistant that introduces itself out loud

Learn

how strings and functions let your program talk

Ship

a program that says three lines in a real voice when you run it

The big idea

In Setup you made your Mac say one line. Now we'll give your assistant a real introduction. To do that, we lean on two ideas you'll use forever.

A string is just text inside quotes — "Hi, I'm your assistant." is a string. Your assistant says strings.

A function is a named skill your program can run. You already have one: speak. When you write speak("Hi"), you're calling the function — telling it to do its job with the words you gave it. The best part of a function is that you write it once and use it as many times as you want.

Your assistant will get a name this stage. For now that name is a plain string you type in. (In the next stage, the assistant will ask for your name instead.)

New words
string
Text inside quotes, like "hello". It's how your program holds words.
function
A named skill, like speak. You write it once and call it whenever you want.
call
To run a function — speak("hi") calls the speak skill with the word hi.
Before you start

Make sure you finished Setup — your Mac should have already said "Hello! I'm alive." If it printed but didn't talk, check the volume first.

Build it

Step 1 — Give your assistant a name and an introduction

Right now your file just says one hello. Let's make the assistant introduce itself like a real character. Pick a name for it — we'll use Pixel, but yours can be anything.

We call speak three times, once per line. Because the program runs top to bottom, the lines come out in order.

Your turn

Plan the three lines

Before you type, say your three introduction lines out loud. What should your assistant say first?

Need a hint?

Each speak(...) call says one string. The first names the assistant, the second says what it is, the third hints at what's coming.

Python code task
Update your file

assistant.py

Where it goes: Replace the single speak("Hello! I'm alive.") line from Setup with these three lines. Keep the import and the speak function exactly as they are.

Only the bottom of the file changes. The speak() helper stays the same.

import subprocess


def speak(text):
print(text)
subprocess.run(["say", text])


speak("Hi! My name is Pixel.")
speak("I am your personal assistant.")
speak("Soon I will be able to do lots of things.")

Run it with uv run assistant.py. Your assistant should say all three lines, one after another. You just gave it a personality with nothing but three strings.

Step 2 — Prove that order matters

Computers do exactly what you say, in the exact order you say it. Move the lines around and you change the conversation.

Think first

Predict the order

If you move the line `speak("I am your personal assistant.")` to the very top, which sentence will your assistant say first?

Check your thinking

It will say 'I am your personal assistant.' first. The program runs top to bottom, so whichever speak() line is highest runs first.

Try swapping two of the lines, run it again, and listen. Then put them back in an order you like.

Understand it

Your assistant feels alive, but there's no magic here — and that's the cool part. It says those three lines because you wrote them, in that order, and called speak three times.

Notice we didn't write subprocess.run(["say", ...]) three times. We wrote it once, inside speak, and reused it. That's the whole point of a function: the hard part is written one time, and from now on "make the Mac talk" is just speak("..."). Every skill you add this week will lean on that one helper.

Try this

Learning beat

Try this

Three short experiments. Predict before you run, then test your guess.

Predict first

Add a fourth speak(...) line with a fun fact about your assistant. Where in the file does it need to go to be said last? Decide before you run.

Compare

Change print(text) inside speak to print("Pixel says:", text). Run it. What changed in the terminal — and did the spoken voice change too? (It shouldn't — only the printed line.)

Connect

Right now the name "Pixel" is typed into the code. What if a different person ran your program and wanted their own name in the greeting? (That's exactly what Stage 2 fixes.)

Test your stage

Stuck? Compare carefully
Answer check
Debug compare only

assistant.py

Where it goes: Compare this against your whole file. Use it only if your program won't run.

This is the full file at the end of Stage 1.

import subprocess


def speak(text):
print(text)
subprocess.run(["say", text])


speak("Hi! My name is Pixel.")
speak("I am your personal assistant.")
speak("Soon I will be able to do lots of things.")
  • Running uv run assistant.py says three lines out loud.
  • The lines come out in the order they appear in your file.
  • The same three lines also print in the terminal.
  • Design check. Read your three strings out loud. Do they sound like a character you'd want to talk to all week?
  • From memory. Without looking, write one line that makes your assistant say "Ready!" Did you use speak("Ready!")?

If it breaks

  • It prints but doesn't talk. The code is fine — this is almost always the volume. Turn it up, unmute, and unplug headphones. We check the volume before the code, every time.
  • command not found: uv. You typed the run command in the wrong place, or this Mac is missing uv. Make sure you're in VS Code's terminal, then raise your hand if it still can't find uv.
  • SyntaxError. Usually a missing quote or parenthesis. Every speak( needs a matching ), and every string needs a quote at both ends.
  • It only says one line. Check that each speak(...) is on its own line and starts at the left edge, not indented.