Unit 01 · lesson
What Is Programming?
System pipeline
How an Idea Becomes a Running Python Program
Read from top to bottom. Each arrow means the next stage uses the result or information produced by the stage above it.
Start with a goal
Decide what you want the computer to do. Example: show the answer to 3 + 4.
Write exact steps
Turn the goal into instructions specific enough that another person could follow them without guessing. That ordered plan is an algorithm.
Write the steps in Python
Use Python syntax to turn the algorithm into source code, such as print(3 + 4), and save it in a .py file.
Run the file with Python
The Python interpreter processes the source code and carries out the instructions the program tells it to execute.
Observe the result
A working program produces visible output. For print(3 + 4), the output is 7.
Break one thing on purpose
Change one character, run the same file again, and compare the new behavior with the working version.
Use the error as evidence
Python can report where it became unable to process or execute the program. The message gives you evidence; you still decide what the code was supposed to do and how to repair it.
Read this concept flow as plain text
- Start with a goal. Decide what you want the computer to do. Example: show the answer to 3 + 4.
- Write exact steps. Turn the goal into instructions specific enough that another person could follow them without guessing. That ordered plan is an algorithm.
- Write the steps in Python. Use Python syntax to turn the algorithm into source code, such as print(3 + 4), and save it in a .py file.
- Run the file with Python. The Python interpreter processes the source code and carries out the instructions the program tells it to execute.
- Observe the result. A working program produces visible output. For print(3 + 4), the output is 7.
- Break one thing on purpose. Change one character, run the same file again, and compare the new behavior with the working version.
- Use the error as evidence. Python can report where it became unable to process or execute the program. The message gives you evidence; you still decide what the code was supposed to do and how to repair it.
Core path: 30 minutes
What are we actually doing when we write code?
Start with a problem, not Python
Before there is Python, there is a problem somebody wants a machine to solve.
Imagine four marked floor positions arranged like this:
- A is where the robot starts.
- B is the next position to the right.
- C is the corner where the robot must turn.
- D is the goal directly below C.
The letters are positions on the floor. They are not commands. The robot starts on A facing right. Its job is to move across B and C, turn right at C, move down to D, and stop.
Make the instructions specific enough for the robot
A, B, C, and D are floor positions. They are not commands. The robot starts on A facing right, turns at C, and must stop on D.
The robot starts on floor position A, facing right.
- MOVE FORWARD
- MOVE FORWARD
- TURN RIGHT
- MOVE FORWARD
- STOP
Run the model once without touching Step. Then reset it and step through one instruction at a time.
Notice something important: TURN RIGHT does not move the robot to a new position. It changes the robot's direction while it stays on C. The next MOVE FORWARD means something different because the robot is now facing a different direction.
A human can look at the floor and say:
Go over there, turn at the corner, and stop at the bottom.
Another human can probably fill in the missing details.
A computer cannot safely do that. "Over there" is not a position. "At the corner" assumes the machine already knows which corner matters. "Stop at the bottom" assumes it can identify the goal from context.
For the robot, we need something closer to:
MOVE FORWARD
MOVE FORWARD
TURN RIGHT
MOVE FORWARD
STOP
Now every step has a specific meaning.
That sequence is an algorithm.
An algorithm is an ordered set of steps for solving a problem or completing a task. Algorithms exist outside programming: recipes, evacuation procedures, troubleshooting checklists, assembly instructions, and driving directions can all be algorithms.
The useful part is not the fancy word. The useful part is that we took an intention that existed in somebody's head and turned it into steps another system can follow.
Precision changes the result
Suppose a recipe says:
Cook the chicken until it is done.
A person with experience might make that work. The instruction still leaves a lot undefined.
Now compare it with:
Cook until the thickest part reaches an internal temperature of 165°F.
The second instruction gives us something we can actually test.
Programming works the same way. "Make the score high" is vague. score >= 100 is testable. "Move over there" is vague. MOVE FORWARD means one defined action.
This is one of programming's first red-pill moments: the computer you imagine in your head and the computer that is actually executing instructions are not always the same machine.
The gap between those two is where a surprising number of bugs live.
The computer does not receive your intention
A beginner often looks at broken code and thinks, "But it knows what I meant."
It does not.
The computer receives instructions, data, and whatever state already exists in the system. Your intention is not secretly transmitted along with the code.
If an instruction is missing, ambiguous, or wrong, the machine may:
- stop with an error;
- keep running and produce the wrong result; or
- do exactly what you wrote while making it painfully obvious that what you wrote was not what you intended.
That last one is going to happen a lot.
The goal is not to become afraid of mistakes. The goal is to get comfortable tracing the difference between what you expected and what actually happened.
So where does Python enter the picture?
Computers ultimately operate using low-level machine instructions represented as bits. Humans generally do not want to build ordinary applications by writing raw machine instructions directly.
Programming languages give us a more usable way to describe computation.
Python is one of many languages. Others include JavaScript, Java, C, C++, Rust, and Go. Different languages make different tradeoffs. C gives developers very direct control over memory. JavaScript is deeply tied to the web platform. Rust puts a lot of effort into catching certain memory-safety problems before software ships.
We are using Python because it lets us focus on the ideas behind programming without making every first step a fight with punctuation and low-level memory details.
Python still demands precision. It just gives us a cleaner surface to learn on.
Source code is the written instruction
When you write:
print("Robot online")
you are writing source code.
Source code is the human-readable text that describes what the program should do. It is not the program actively running. A file such as hello.py can sit on disk for a week doing absolutely nothing.
Think about the difference between a recipe card and a meal. The recipe contains instructions. Something still has to carry them out.
That "something" for our Python files is the subject of Lesson 2: the Python interpreter.
Tiny change, different instruction
Before running this, predict both lines of output:
Tiny punctuation can change what Python does
Quotation marks tell Python to treat characters as text. Without quotation marks, Python evaluates the expression first.
- SOURCE LINEprint("3 + 4")treat as
- STRING TEXTcharacters stay charactersprints
- OUTPUT3 + 4compare
- SOURCE LINEprint(3 + 4)evaluate
- OUTPUT7
Now run the example and compare the result with your prediction:
Run the code to see output.
Change the quotation marks and run again. The point is to compare literal text with an evaluated expression.
The first line contains text inside quotation marks, so Python prints the characters 3 + 4.
The second line contains a numeric expression, so Python evaluates the expression first and prints the result.
Expected output:
3 + 4
7
Only a pair of quotation marks changed. The machine did something completely different.
That is the point.
Try being the machine
Read these instructions literally:
Stand up.
Turn right.
Walk three steps.
Turn left.
Touch the desk.
Now compare them with:
Move over there.
Turn when you get close.
Touch that thing.
The second set might make sense if you can see the room and infer what the writer meant. A program does not get to invent those missing definitions for us.
When you write instructions this week, keep asking one question:
What, exactly, would the machine have to know to perform this step?
Optional video: What is Python? Why Python is so popular. If your school network blocks the embedded player, open the video directly on YouTube.
Vocabulary lab
Flip the idea, not just the card
Explain the term before you reveal the back. Then compare your explanation with the definition, example, and warning.
Read all terms without animation
- Algorithm
- An ordered set of steps used to solve a problem or complete a task. Example: Move forward, move forward, turn right, move forward, stop. Do not confuse it with: A vague goal such as get the robot over there.
- Programming Language
- A formal language used to express instructions and computation for a computer system. Example: Python, JavaScript, Java, C++, and Rust are programming languages. Do not confuse it with: A natural-language request that depends on human interpretation.
- Source Code
- Human-readable program instructions written in a programming language. Example: print("Robot online") is Python source code. Do not confuse it with: The running process that executes the source code.
- Program
- Instructions and related data organized so a computer can perform a task when the software is executed. Example: A Python script that prints a system-status report. Do not confuse it with: An idea for software that has not been expressed as executable instructions.
- Precision
- Using instructions and conditions specific enough that the system does not need to guess what you mean. Example: Turn right at position C is more precise than turn over there. Do not confuse it with: Adding extra words without defining the action more clearly.