Chapter 1: Setup & “Hello, World!”
Get your environment ready, write your first Python script, and run it from the console.
Downloadchapter1.py
Objectives
- Install Python 3.x and verify the version
- Create and activate a virtual environment
- Write a basic “Hello, World!” script
- Run a
.py
file from the terminal
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
- Modify
src/chapter1.py
to print your name and the current year. - Write two
print()
statements on separate lines. - Deactivate and reactivate your virtual environment; confirm you’re in
venv
.