क्या पायथन कोड संकलित या व्याख्यायित है?
Is python code compiled or interpreted?
A)
B)
C)
D)
Explanation:
Python is an interpreted language, but it has some features of compiled languages as well. Here's how it works:
1. Python as an Interpreted Language:
- Interpreter: Python code is executed by an interpreter, which means the source code is executed line-by-line, at runtime, rather than being converted into machine code ahead of time.
- This makes Python easier to debug and allows for quick testing and prototyping since you can run the code directly without a separate compilation step.
2. How Python Executes Code:
- Step 1: When you run a Python program, the Python interpreter first converts the code into an intermediate form called bytecode.
- Step 2: This bytecode is then executed by the Python Virtual Machine (PVM).
The bytecode is a lower-level representation of your code, which can be executed efficiently by the interpreter. This is why Python is sometimes said to be compiled to bytecode, but it is still ultimately interpreted when run.
3. What Happens Under the Hood:
- When you run a Python script, the interpreter performs the following:
- Parsing: The Python source code (
.py
file) is parsed and translated into an intermediate bytecode (.pyc
or.pyo
files). - Execution: This bytecode is then executed by the Python Virtual Machine (PVM), which is the interpreter itself.
- Parsing: The Python source code (