Skip to content

Exercise: Hello Claude

Level: Beginner Time: 15-20 minutes Skills: Basic commands, file operations, running code

Objective

Get comfortable with Claude Code by creating, modifying, and running a simple program.

Setup

  1. Navigate to this exercise directory:

    cd exercises/01-hello-claude
    

  2. Start Claude Code:

    claude
    

Tasks

Complete these tasks using only Claude Code (don't edit files manually):

Task 1: Create a Greeter

Ask Claude to create a file called greeter.py that: - Asks for the user's name - Prints a personalized greeting

Hint: "Create a Python file called greeter.py that asks for a name and prints a greeting"

Task 2: Run the Program

Ask Claude to run your program.

Hint: "Run greeter.py"

Task 3: Add a Feature

Modify greeter.py to also: - Ask for the user's favorite color - Include the color in the greeting

Hint: "Update greeter.py to also ask for and include their favorite color"

Task 4: Add a Time-Based Greeting

Modify greeter.py so the greeting changes based on time of day: - "Good morning" before noon - "Good afternoon" from noon to 6pm - "Good evening" after 6pm

Hint: "Add time-based greetings - morning, afternoon, or evening"

Task 5: Run and Verify

Run the final program and test it.

Success Criteria

Your final greeter.py should: - [ ] Ask for the user's name - [ ] Ask for their favorite color - [ ] Display a time-appropriate greeting - [ ] Include both name and color in the output

Bonus Challenges

  1. Add error handling for empty inputs
  2. Create a greeter_test.py file with simple tests
  3. Add a "goodbye" message at the end

Reflection Questions

After completing this exercise, consider: - How did you phrase your requests to Claude? - Did Claude understand your intent on the first try? - What did you learn about effective prompting?

Solution

Don't peek until you've tried! But if you're stuck, here's an example interaction:

Click to reveal example prompts
> Create a Python file called greeter.py that:
  1. Imports datetime
  2. Asks for the user's name
  3. Asks for their favorite color
  4. Determines if it's morning, afternoon, or evening
  5. Prints a greeting like "Good morning, Alice! I hear you love blue!"

> Run greeter.py to test it