Level 0 / Project 01 - Terminal Hello Lab¶
Home: README
Try in Browser: Run this exercise online — no installation needed!
Before You Start¶
Recall these prerequisites before diving in:
- Can you create a variable and print its value? (name = "Ada" then print(name))
- Can you use an f-string to combine text and variables? (f"Hello, {name}")
Estimated time: 15 minutes
Learn Your Way¶
| Read | Build | Watch | Test | Review | Visualize | Try |
|---|---|---|---|---|---|---|
| Concept | This project | Walkthrough | Quiz | Flashcards | Diagram | Browser |
Focus¶
- print output, variables, and command execution basics
Why this project exists¶
Your very first Python script. You will print text to the terminal, use variables to store data, and see how f-strings build dynamic output. Every programmer starts here.
Run (copy/paste)¶
Use <repo-root> as the folder containing this repository's README.md.
The program will ask for your name and learning day, then print output.
Expected terminal output¶
What is your name? Ada
What day of your Python journey is it? 7
****************************************
TERMINAL HELLO LAB
****************************************
Hello, Ada! Welcome to Python.
Day 7 of your Python journey.
Fun fact: Python is named after Monty Python,
not the snake!
--- Your Info Card ---
name: Ada
language: Python
learning_day: 7
greeting: Hello, Ada! Welcome to Python.
5 passed
Expected artifacts¶
- Passing tests
- Updated
notes.md
Worked Example¶
Here is a similar (but different) problem, solved step by step.
Problem: Write a function that builds a welcome message with the current date.
Step 1: Think about what we need. We need a name, today's date, and a formatted string.
from datetime import date
def build_welcome(name):
today = date.today().strftime("%B %d, %Y")
return f"Welcome, {name}! Today is {today}."
Step 2: Think about the output. What should this look like?
Step 3: Think about edge cases. What if name is empty?
def build_welcome(name):
if not name or not name.strip():
name = "friend"
today = date.today().strftime("%B %d, %Y")
return f"Welcome, {name}! Today is {today}."
The thought process: Start with the simplest version that works. Then add a guard for bad input. This is the pattern you will use in this project and every project after it.
Checkpoint: Baseline code runs and all tests pass. Commit your work before continuing.
Alter it (required) — Extension¶
- Add a
build_greeting_box()function that wraps the greeting in a box made of+,-, and|characters. - Ask the user if they want UPPERCASE output. If they type "yes", print everything in upper case.
- Re-run script and tests.
Break it (required) — Core¶
- Type nothing when asked for your name (just press Enter) -- what happens to the greeting and banner?
- Type only spaces as your name -- does
build_banner()handle it or crash? - Try typing letters instead of a number for the day -- what error do you get?
Fix it (required) — Core¶
- Add a guard in
greet()that returns a default message for empty names. - Add a check that the day is a valid positive number, with a helpful error message.
- Add a test that verifies empty-name handling.
Checkpoint: All modifications done, tests still pass. Good time to review your changes.
Explain it (teach-back)¶
- What does
f"Hello, {name}!"do differently from"Hello, " + name + "!"? - Why does
build_banner()uselen(text) + 4for the border width? - How does the
if __name__ == "__main__"guard work and why is it needed? - Where would greeting templates be used in real software (email systems, CLI tools)?
Mastery check¶
You can move on when you can: - run baseline without docs, - explain one core function line-by-line, - break and recover in one session, - keep tests passing after your change.
Related Concepts¶
Stuck? Ask AI¶
If you are stuck after trying for 20 minutes, use one of these prompts. They are designed to help you learn without giving away the answer.
- "I am working on Terminal Hello Lab. I got this error: [paste error]. Can you explain what this error means without giving me the fix?"
- "I am trying to build a banner with asterisks. I know I need
len()and string multiplication, but my output looks wrong. Can you give me a hint about what I might be calculating incorrectly?" - "Can you explain f-strings with a simple example that is different from my project?"
| ← Prev | Home | Next → |
|---|---|---|