Chapter 1: Setup & “Hello, World!”

Get your environment ready, write your first Python script, and run it from the console.

Download chapter1.py

Objectives

1. Installing Python & Setting Up venv

Visit python.org/downloads and install the latest Python 3 release. Then verify in your terminal:

python3 --version

Create a project folder and enter it:

mkdir zero_to_hero && cd zero_to_hero

Initialize a virtual environment:

python3 -m venv venv

Activate it:


# macOS / Linux
source venv/bin/activate

# Windows PowerShell
venv\Scripts\Activate.ps1
      

2. Writing “Hello, World!”

Create src/chapter1.py with:

print("Hello, World!")

Save and run:

python src/chapter1.py

You should see:

Hello, World!

Exercises

  1. Modify src/chapter1.py to print your name and the current year.
  2. Write two print() statements on separate lines.
  3. Deactivate and reactivate your virtual environment; confirm you’re in venv.