What’s one thing you learned? What’s still confusing?
Variables, Types & Operators
Create variables, master Python's core types, type conversion, and f-strings.
Mini-Project: Mad Libs Generator
Ship your first interactive Python program in 20 minutes — collect input, weave a story with f-strings.
Control Flow: Decisions, Loops & Modern Python
if/elif/else, for/while loops, break/continue, walrus operator, and match/case pattern matching.
Interactive Labs for This Track
Loop Visualizer
You're a factory robot repeating the same task on an assembly line — watch how loops automate repetitive work
List Slicing
You have a playlist of 50 songs — grab just tracks 10 through 20 with a single slice expression
Sorting Algorithms
You're organizing a library of 10,000 books — which sorting method is fastest?
Ask questions, share insights
What does this print?
Python is a programming language -- a way to write instructions that a computer can understand and execute. It was created in 1991 by Guido van Rossum (he named it after Monty Python, the comedy group, not the snake).
Here is why Python dominates the AI world:
System.out.println("Hello, AI!");print("Hello, AI!")Python wins. Every time.
scikit-learn. Want to build a neural network? Import PyTorch. Want to analyze data? Import pandas. Thousands of developers have built tools that you can use for free.print("Hello, AI!")You just ran your first Python program. Output appears under the code. No install, no terminal, no setup.
print(...) is a built-in function that displays whatever you give it."Hello, AI!" is a string — text wrapped in quotes.Try changing the text inside the quotes — click in the code, edit, and Run again. Make it say your name. This is your laboratory for the next 53 lessons.
You're already using one. Every Run button in this course IS a REPL — paste any Python expression, hit Run, see the result. Try a few:
print("Hello, AI!")
print(2 + 2)
print(100 * 365)>>> prompt in your terminal. The behaviour is identical — it's the same Python.The REPL is for experimentation. Calculator math, string fiddling, quick sanity-checks. By lesson 53 you'll use it constantly — to test a snippet before pasting it into a real file.
A real program has multiple lines. Python runs them top-to-bottom, one at a time. Try this:
# My first Python program
print("Hello, AI!")
print("I am learning Python.")
print("This is going to be awesome.")You should see three lines of output. Let's break it down:
# starts a comment. Python ignores everything after # on that line. Comments are notes for humansprint() is a function that displays text on the screen. Whatever you put inside the parentheses gets printed"Hello, AI!" is a string -- a piece of text wrapped in quotes. You can use single quotes 'like this' or double quotes "like this" -- Python treats them the sameWhat does print(3 + 4) output?
3 + 4 first (getting 7), then print() displays the result. Python is smart enough to do the math before printing. Notice there are no quotes around 3 + 4 -- it is not a string, it is a math expression.Python is incredible at math. Here are the basic operators:
| Operator | What It Does | Example | Result |
|---|---|---|---|
+ | Addition | 10 + 3 | 13 |
- | Subtraction | 10 - 3 | 7 |
* | Multiplication | 10 * 3 | 30 |
Let us try some AI-related calculations:
# How many parameters does GPT-4 have? Estimated at 1.7 trillion
gpt4_params = 1_700_000_000_000
print("GPT-4 parameters:", gpt4_params)
# If each parameter is a 32-bit float (4 bytes), how many GB is that?
bytes_total = gpt4_params * 4
gb_total = bytes_total / (1024 ** 3)
print("GPT-4 model size (approx):", gb_total, "GB")
# Python follows order of operations (PEMDAS)
result = 2 + 3 * 4
print("2 + 3 * 4 =", result) # 14, not 20
# Use parentheses to change the order
result2 = (2 + 3) * 4
print("(2 + 3) * 4 =", result2) # 20Notice a few things:
1_700_000_000_000 is the same as 1700000000000What does print(7 / 2) output? And print(7 // 2)?
/ always produces a float (decimal), even when the numbers divide evenly: 4 / 2 is 2.0, not 2. The // (floor division) drops the fractional part and gives you an integer when both operands are integers. This trips up beginners coming from languages like C or Java where / between integers truncates.AI deals with text constantly -- chatbots process text, language models generate text, and NLP (Natural Language Processing) is one of the hottest areas in AI. Here is how Python handles text:
# Strings are text wrapped in quotes
greeting = "Hello"
name = "AI Builder"
# Concatenation -- joining strings together
message = greeting + ", " + name + "!"
print(message) # Hello, AI Builder!
# String multiplication -- yes, this works!
print("Ha" * 3) # HaHaHa
print("-" * 40) # prints a line of 40 dashes
# The len() function tells you how many characters a string has
prompt = "Explain quantum physics like I am five"
print("Prompt length:", len(prompt)) # 38
# Strings are case-sensitive
print("python" == "Python") # False
print("python" == "python") # TrueTime to experiment. Run this code, then try the challenges in the comments:
Tests · Try each challenge one at a time. Run after each change to see your result!
Everyone makes these. Here is how to fix them:
# Wrong -- Python thinks Hello is a variable name
print(Hello) # NameError: name 'Hello' is not defined
# Right -- wrap text in quotes
print("Hello") # Hello# Wrong -- started with double, ended with single
print("Hello') # SyntaxError: mismatched quotes
# Right -- match your quotes
print("Hello") # or print('Hello')# Wrong -- Print with capital P does not exist
Print("Hello") # NameError: name 'Print' is not defined
# Right -- lowercase print
print("Hello")# Wrong in Python 3 (this is Python 2 syntax)
print "Hello" # SyntaxError: Missing parentheses
# Right -- print is a function, needs parentheses
print("Hello")These errors are not failures -- they are how you learn. Every programmer in the world has made every one of these mistakes. The key is reading the error message. Python tells you what went wrong and even points to the exact line.
Which command runs a Python file named myfile.py from the terminal?
Interactive Lab
Step through Python loops line by line and watch exactly what each iteration does — perfect for building mental models
python3 in your terminal and start coding. No setup, no files neededprint() displays output -- it is the most basic and most useful function. You will use it in every program you write+, -, *, /, // (floor division), % (remainder), and ** (power)+, repeat them with *, and measure them with len()This program was copy-pasted from an old tutorial and uses Python 2 syntax. Fix it so it runs on Python 3 and prints the greeting.
Hello, AI! I am learning Python 3.
What does REPL stand for?
python3 --version
Python 3.12.4. If you want the latest version, install via Homebrew: brew install python@3.12.python --versionMost distros ship with Python 3. Open a terminal:
python3 --version
sudo apt install python3 python3-pip python3-venv (Ubuntu/Debian) or sudo dnf install python3 python3-pip (Fedora).python3 -c "print('Hello from local Python!')"
Hello from local Python!, you're set up.python3 -m venv .venv
source .venv/bin/activate # macOS / Linux
.venv\Scripts\activate # Windows
pip install requests # installs into THIS project only
deactivate. The Modules & Packages lesson (order 20) covers this in depth./ |
| Division |
10 / 3 |
3.333... |
// | Floor division (rounds down) | 10 // 3 | 3 |
% | Modulo (remainder) | 10 % 3 | 1 |
** | Exponentiation (power) | 2 ** 10 | 1024 |