Python is an interpreted programming language. The computer's processor does not directly execute the Python source code. Instead, it goes through a two-step process.

First, the Python source code is compiled into bytecode. Bytecode is a low-level presentation of code that is easier and faster to interpret than source code. The compiled bytecode is stored in a ".pyc" (compiled Python) file extension for interpretation.

Then the Python interpreter reads the bytecode line by line during the interpretation phase. It translates bytecode instructions into machine code, which is understood and executed by the computer's processor.

There are two modes for using the Python interpreter:
  1. Interactive Mode
  2. Script Mode

Interactive Mode

Without passing the Python script file to the interpreter, directly execute code to the Python prompt.


>>> 2+6



The chevron at the beginning of the first line, i.e., the symbol ">>>", is a sign that the Python interpreter uses to indicate that it is ready. As the above example shows, if the programmer types 2+6, the interpreter answers 8.

Script Mode

Alternatively, programmers can store the Python script source code in a file with a ".py" extension and use the interpreter to execute the file's contents. For the interpreter to run the script, you must tell the interpreter the file's name. For example, if you have a script named "" and you are working on Unix, to run the script, you would type:


Working with the interactive mode is better when Python programmers deal with small pieces of code because you can type and execute them immediately, but when the code is longer than 2-4 lines, using scripts for coding can help modify the code and use the code in the future.

Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram