Phase 02 · Python FoundationsLesson 1 of 8
Introduction to Python & Setup
Why Python, and how to install it and run your first program.
The problem
Python is the language of AI. Almost every machine learning library, data tool and agent framework you'll meet in this roadmap is written for Python first. The good news: it's also one of the friendliest languages to learn, because its code reads almost like plain English.
The concept
Why Python?#
- Readable: indentation and simple keywords make code easy to follow.
- Huge ecosystem: libraries such as NumPy, pandas, scikit-learn, PyTorch, LangChain and the official LLM SDKs.
- Versatile: scripts, web backends, data analysis, automation and AI all use the same language.
- Interpreted: you can run a line and see the result immediately, which makes experimenting fast.
Installing Python#
- Download Python 3 from python.org (any recent version is fine).
- On Windows, tick "Add Python to PATH" on the first installer screen. This lets you run Python from any terminal.
- Open a terminal and check the install:
python --version
# On macOS/Linux you may need:
python3 --version
If you see something like Python 3.12.4, you're ready.
Two ways to run Python#
1. The interactive REPL. Type python in a terminal and you get a >>> prompt. Each line runs immediately, which is perfect for quick experiments.
>>> 2 + 3
5
>>> "AI" * 3
'AIAIAI'
2. Script files. For real programs, save code in a file ending in .py and run it:
# hello.py
name = "AI world"
print(f"Hello, {name}!")
python hello.py
# Hello, AI world!
Two ways to run Python
Interactive REPL
- Type
pythonin a terminal - You get a
>>>prompt - Each line runs immediately
- Perfect for quick experiments
Script files
- Save code in a file ending in
.py - Run it with
python hello.py - For real programs
Set up a code editor#
Use VS Code with the official Python extension. You get syntax highlighting, error hints, autocomplete and a one-click run button. Later in this track you'll also use AI-assisted tools such as Claude Code inside the same workflow.
Your first mental model#
A Python program is a list of instructions that run top to bottom. Each line does one small thing: store a value, make a decision, repeat a step or call a function. Every lesson in this module adds one more kind of instruction to your toolkit.
Try it
Your task · about 10 minutes
Create hello.py containing print("Hello, AI world!") and run it from your terminal.
Recap & next
Key takeaways
- Python is a high-level, readable, interpreted language and the default language for AI and data work.
- Install Python 3 from python.org. On Windows, tick "Add Python to PATH" during setup.
- Check the install with
python --version(orpython3 --versionon macOS/Linux). - Run code interactively in the REPL, or save it in a
.pyfile and runpython file.py. - Use a code editor such as VS Code with the Python extension.
Quick check
2 questions · instant feedback
Go deeper
Finished this lesson?
Mark it complete to track your progress and keep your streak going.

