LESSON 2
How Python Works
Learning objective: Learn how Python runs your code line by line.
Understand
Python is an interpreted language.
Python code is run by the interpreter, which reads and executes your script top to bottom. You can run whole files or type commands one at a time in an interactive shell. There is no separate compile step to worry about.
Analogy: The interpreter is like a translator reading your instructions aloud one line at a time.
See It in Action
Two lines run in order:
print("First")
print("Second")How it works: Python runs the first line, then the second, so the output appears in that order.
Try It Yourself
- Run a script with two print lines.
- Swap their order and rerun.
- Try typing a command in the interactive shell.
Quick Quiz
How does Python run your code?
Challenge
Write a short script whose output order proves lines run top to bottom.
Success condition: Your output appears in the same order as your lines.
+10 XP
Lesson Complete
You answered correctly and completed the required practice. Your progress has been saved on this device.
Continue to next lesson →