
Python an Interpreted Language
Python is considered an interpreted language because the code is executed line by line by the Python Virtual Machine (PVM) instead of being compiled directly into machine code.
๐น Explanation
- Python source code (
.py
file) is first compiled into bytecode (.pyc
file inside__pycache__
folder). - This bytecode is not machine code.
- The Python Interpreter (PVM) reads and executes the bytecode line by line.
- Hence, Python is interpreted, not purely compiled.
๐น Steps of Execution
- Source Code โ
hello.py
- Compilation โ Converted to Bytecode (
__pycache__/hello.cpython-<version>.pyc
) - Interpretation โ Bytecode executed by PVM
๐น Example
File: hello.py
print("Hello, World!")
Run in terminal:
python hello.py
Output:
Hello, World!
โ
Summary:
Python first compiles code into bytecode but does not directly generate machine code. Instead, the PVM interprets bytecode line by line, making Python an interpreted language.