PART 1 · PYTHON FROM ZERO · LESSON 1
What Python is, and running your first program
FreeLesson 3 of 78
Python is a language for giving a computer step-by-step instructions in words that read almost like English. This page gets one running.
A Python program is a text file ending in .py. Python reads it from the top line to the bottom, one instruction at a time. Data engineers use it to read files, clean data, call APIs and load warehouses, because the code stays short and the libraries already exist for almost every job.
Step 1: set up once
# 1. Check Python is installed (3.10 or newer)
python3 --version
# 2. Make a folder and a virtual environment for it
mkdir python_de && cd python_de
python3 -m venv .venv
source .venv/bin/activate
# on Windows: .venv\Scripts\activate
# 3. Save the code on the right as hello.py, then run it
python3 hello.pyNo Python yet? Install it from python.org (tick "Add Python to PATH" on Windows). Use VS Code as your editor, or Jupyter if you like running code in small pieces.
Step 2: your first program
# Lines starting with # are comments.
# Python ignores them; they are notes for humans.
print("Hello, data engineer!")
print("Orders today:", 15)
print(2 + 3)Output
Hello, data engineer! Orders today: 15 5
Three rules Python is strict about
amount = 1198
if amount > 1000:
print("big order") # 4 spaces: inside the if
print("done") # back left: after the ifOutput
big order done
print("Amount")
Print("Amount") # capital P: another nameOutput
Amount NameError: name 'Print' is not defined. Did you mean: 'print'?
| Word | Meaning in plain English |
|---|---|
| Program / script | A .py file with instructions |
| Terminal | The text window where you type commands like python3 hello.py |
| Interpreter | The python3 program that reads your file and runs it line by line |
| Output | Whatever your program prints. Every grey OUTPUT box in this book is real output |
| Virtual environment (.venv) | A private folder of libraries for one project, so projects do not clash |
Try it yourself before moving on
- Print your name and your city on two separate lines.
- Print the result of 1198 + 796 with a label in front of it.
- Remove the 4 spaces before print("big order") and read the error Python gives you.
Watch the free lesson
The same topic in the Free Lessons library, free with a sign-in.