Learn computing fundamentals, programming, algorithms, systems, and software engineering.
A program is a sequence of instructions that a computer carries out, one after another. To write those instructions you need four building blocks: a way to store information (variables), a way to make decisions (conditionals), a way to repeat work (loops), and a way to package reusable steps (functions). This lesson introduces all four using Python, a language designed to read almost like plain English. Variables are named containers for values. In Python you create one by assigning a value with the equals sign, for example name = "Ada". The equals sign means "store the value on the right under the name on the left"; it does not compare anything. Python decides the type of each value automatically at runtime — integers, decimals (floats), text (strings), and true/false (booleans) are the most common — so you never write a type declaration. Conditionals let a program take different paths. An if statement checks a condition and runs its body only when that condition is true. You add elif to test further conditions and else to catch everything that did not match. Conditions are built from comparisons such as ==, !=, <, and >. Loops repeat work. A for loop walks over a collection (for example each number from range(5)), and a while loop keeps running as long as a condition stays true. Functions package logic under a name, accept inputs (parameters), and hand a result back with return. Common mistakes for beginners include writing = when they mean ==, forgetting that indentation defines which lines belong to a block, and assuming range(3) produces 1, 2, 3 when it actually produces 0, 1, 2.
Programming is the process of writing instructions that a computer can carry out. A program is a sequence of those instructions, written in a language people can read, that tells the machine exactly what to do step by step.
Every value has a type. The type decides what you can do with the value and how it is stored in memory.
| Type | Description | Example |
|---|---|---|
| Integer (int) | Whole numbers | 42, -7, 0 |
| Float (float) | Numbers with a decimal point | 3.14, -0.5 |
| String (str) | Text, written in quotes | "hello" |
| Boolean (bool) | True or false | True, False |
Operators combine values into expressions, and an expression always evaluates to a single value. Do not confuse = (assignment) with == (equality).
| Operator | Meaning | Example | Result |
|---|---|---|---|
| + | Addition | 2 + 3 | 5 |
| - | Subtraction | 7 - 4 | 3 |
| * | Multiplication | 3 * 4 | 12 |
| / | Division | 7 / 2 | 3.5 |
| == | Equality | 5 == 5 | True |
| = | Assignment | x = 5 | stores 5 in x |
Indentation (the leading spaces) is not optional in Python — it marks the block of code that belongs to each if, for, while, or def.
Each value has a type that Python works out for you. The type() function reveals it.
Ada <class 'int'> <class 'float'> <class 'bool'>
Only the first branch whose condition is true runs; the rest are skipped.
Warm
A function can be called from inside a loop. range(1, 5) yields 1, 2, 3, 4.
1 squared is 1 2 squared is 4 3 squared is 9 4 squared is 16