What is Python?
Python appears early in this syllabus because it sets the ground rules for everything that follows. Before we write useful programs or build AI-enabled systems, we need a clear mental model of what Python actually is and what happens when we run it. This lesson exists to remove mystery from that process and replace it with something concrete and predictable.
Python as a language and runtime
Python is both a programming language and a runtime environment. The language is the set of rules that define what valid Python code looks like. The runtime is the system that reads that code and makes it do something.
When we write Python, we are writing instructions meant to be read and executed by a Python runtime. There is no separate compilation step that turns our code into another form first. The runtime works directly from the source code we write.
The Python interpreter
The Python interpreter is the program that performs this work. It reads Python source code, understands it according to the rules of the language, and executes it.
When people say “Python is interpreted,” this is what they mean. The interpreter processes code as a sequence of instructions and carries them out immediately. Our programs run inside the interpreter, and its behavior defines how Python code actually behaves at runtime.
Python source files and .py
Python programs are usually stored in plain text files with a .py file extension. These files contain Python source code and nothing else.
A .py file is not special on its own. It becomes meaningful only when the Python interpreter is asked to read it. At that point, the file is treated as a Python program and executed according to its contents.
Top-to-bottom execution
Python executes code from top to bottom, one statement at a time. The order in which lines appear in a file is the order in which they run.
This sequential execution model is central to understanding Python programs. Variables are created when their assignment statements are reached, functions are defined when their definitions are encountered, and actions happen exactly where they appear in the file.
What it means to run a Python program
To run a Python program is to ask the Python interpreter to load a .py file and execute its contents. The interpreter starts at the top of the file, executes each statement in order, and stops when it reaches the end.
Here is the simplest possible example of running a Python program from the command line:
python example.py
In this case, python launches the interpreter, and example.py is the source file it executes.
Conclusion
We now have a working picture of Python as a language that runs directly inside an interpreter, executing source files from top to bottom. This is enough to orient us when we begin writing and running real programs. The mechanics are simple, and that simplicity will carry through everything we build on top of it.