What Python Runs
Python runs code. Code is text written in a form Python understands.
For now, think of Python as a careful reader. It starts at the top, reads one instruction, runs it, and then moves to the next instruction.
Keep this distinction in view:
Python does not run your intention. It runs the exact code it receives.
If the code says print(2 + 3), Python computes 5 and displays it. If the
code has a spelling mistake, Python reports an error. This is not a personal
judgment; it is Python telling you which instruction it could not run.
The word print means "show this on the screen." It is one of the first tools
you use to make a program visible.
Code Is a Sequence of Instructions
Consider this program:
Python runs the lines in order:
first
second
third
Line order
Run the program, then edit the words and run it again.
Ready to run.
The output appears in the same order because each line runs after the previous line finishes.
If you edit "first" to another word and run again, Python will show the new
word. It does not remember what you meant before. It runs the code that is there
now.
Expressions Produce Values
Some pieces of code produce a result:
2 + 3
The result is 5. In a script, Python does not automatically show that result.
You usually use print() when you want to see it:
print(2 + 3)
This distinction matters later. A program may compute something correctly, but you will not see it unless the program prints it, plots it, saves it, or passes it to another step.
Instructions Do Work
An instruction tells Python to do something. This line is an instruction:
print("loss:", 0.42)
It tells Python to call print() with two pieces of information. The printed
output is:
loss: 0.42
You will see this pattern constantly in experiments. A script computes something, then prints enough evidence for you to inspect what happened.
Code Is Not Output
Do not confuse the code with the output.
Code:
print(2 + 3)
Output:
5
The output does not contain print. The output is what happened after Python
ran the instruction.
In what order does this program print the letters?
Select one choice, then check.
HintFollow the lines
Start at the top. Each print() finishes before Python moves to the next
line.
SolutionPreserve execution order
Python first runs print("A"), then runs print("B"). Each call prints its
own line, so the output is A followed by B.
The First Job
Python runs exact instructions. Your first job as a programmer is to make those instructions visible: code on one side, output on the other. When those two match your expectation, you have learned something real.