Learn Python the way you'll actually use it — by running it.
Five short, hands-on modules. Every idea comes with a live console you can poke at, so you see exactly what Python does instead of just reading about it.
Operators
Arithmetic, comparison, and logical operators — the building blocks of every expression.
Input & Expressions
Get input from users, build math expressions, and run simple calculations.
Conditionals
if, elif, else, and nested conditions to make your programs decide things.
Loops
for loops, while loops, and nested loops to repeat work automatically.
Functions
Package logic into reusable functions with parameters and return values.
Operators
Operators are the small symbols that do the work in Python: adding numbers, comparing values, and combining true/false logic. There are three families you'll use constantly.
| Type | Operators | Example | Meaning |
|---|---|---|---|
| Arithmetic | + - * / // % ** | 7 // 2 | Floor division → 3 |
| Comparison | == != > < >= <= | 5 >= 5 | Returns True or False |
| Logical | and or not | True and False | Combines booleans → False |
Playground: Arithmetic & Comparison
Playground: Logical Operators
Quick check
10 % 3 evaluate to?True and False evaluates to:User Input, Expressions & Calculations
input() pauses a program and waits for the person using it to type something. Whatever they type comes back as text (a string), which you can then use inside math expressions.
Try it: input()
Simple calculation: BMI calculator
A classic "simple calculation" program: take a couple of numbers, plug them into a formula, print the result.
Quick check
input() always returns a value of which type?if, elif, else & Nested Conditions
Conditions let your program choose what to do. Python checks each branch top to bottom and runs the first one that's true.
Try it: age classifier
Nested conditions: grading system
A nested condition is just an if inside another if — here, each grade band is a deeper check once the score passes the previous test.
Quick check
for Loop, while Loop & Nested Loops
Loops repeat work so you don't have to copy-paste code. A for loop repeats a fixed number of times; a while loop repeats until a condition becomes false.
Step through a for loop
i
while loop: countdown
Nested loops: multiplication table
A loop inside a loop. The outer loop picks a row, and for every row, the inner loop fills in every column — that's why the grid fills cell by cell.
Quick check
for i in range(2, 8): run?while loop stops when:Functions, Parameters & Return Values
A function is a reusable machine: you feed it input (parameters), it does some work, and it hands back a result (the return value).
The function machine
Quick check
def add(a, b):, what are a and b called?return statement?