Video
A strong first programming lecture if you want an external walk-through alongside the notes.
Lesson assets
Keep the notes in-page. Use this column for your own PDFs first: recitations, labs, homework, or an optional downloadable handout.
alternate video
Alternate video: freeCodeCamp Python basics
A longer outside walkthrough if you want the same foundations taught with a different pacing and style.
recitation
Recitation 1 PDF
Example of how your own recitation sheet or guided walkthrough can hang directly off the lesson.
lab
Lab 1 PDF
Swap this for your own coding lab sheet, notebook export, or starter exercises.
hw
Homework 1 PDF
Sample local PDF slot for the first homework set.
What are we actually doing when we program?
A program is just a precise list of instructions that transforms input into output.
That sounds small, but it already contains most of the course:
- we need data,
- we need rules for transforming that data,
- and we need a way to reason about whether the rules do what we claim.
In Python, the smallest examples already show the whole picture.
name = input("Name: ")
print(f"hello, {name}")
This has an input channel, a stored variable, and an output rule. Nothing magical happened. The machine just followed instructions exactly.
Variables and expressions
Think of a variable as a name bound to a value.
x = 7
y = 2 * x + 5
Now x stores 7, and y stores 19.
Mathematically, this is close to substitution, but not identical. In algebra, x = 7 describes equality. In Python, x = 7 is assignment: take the object 7 and bind the name x to it.
That distinction matters.
x = 7
x = x + 1
This is nonsense as an equation in pure math, but perfectly valid as a program. The second line means: read the old value of x, add 1, then store the new result back into x.
First mental model
The machine is brutally literal.
If you want a good programming habit early, read each line and ask:
- What values exist right now?
- What operation is this line performing?
- What new state exists after this line executes?
That habit prevents a lot of fake understanding.
A first function
Functions let us package repeated logic into a reusable rule.
def square(n: float) -> float:
return n * n
Mathematically, this is the rule
In code, the same idea becomes a named block that can be executed on demand.
print(square(3))
print(square(1.5))
The point is not just convenience. A function forces us to isolate the input, isolate the output, and separate the rule from the rest of the program.
Worked example: Celsius to Fahrenheit
The conversion formula is
That becomes:
def c_to_f(celsius: float) -> float:
return (9 / 5) * celsius + 32
This is the kind of bridge I want this course to keep making:
- mathematics gives the structure,
- code makes the structure executable.
Recitation-style checks
Try these before looking anywhere else:
- Write a function
cube(n)that returns . - Ask the user for two numbers and print their average.
- Explain, in words, why
x = x + 1is legal in Python but not a true algebraic identity.
A small debugging note
Most beginner bugs are not deep.
They usually come from one of four things:
- wrong indentation,
- misspelled names,
- mixing strings and numbers,
- misunderstanding the order in which lines execute.
That is good news. It means debugging is often just careful reading.