Vidyalelo
Python · Q11

Python Introduction and basic

Programming · Python · question 11

Q11

Is Python code compiled or interpreted?

A.
Python code is both compiled and interpreted
Answer
B.
Python code is neither compiled nor interpreted
C.
Python code is only compiled
D.
Python code is only interpreted

Answer: Option A

Solution

Answer: Option A
Solution:
Python code is both compiled and interpreted.
When you run a Python script, the source code is first compiled into bytecode by the Python interpreter. This bytecode is then executed by the Python Virtual Machine (PVM). Thus, Python combines elements of both compilation and interpretation. The compilation step translates the human-readable source code into bytecode, while the interpretation step executes the bytecode instructions. This hybrid approach allows Python to achieve a balance between performance and flexibility.