WeLearn

Grade 12 Information Technology · Lesson 6.3

The Python Interpreter

Unit 6: Fundamentals of Programming

Computers execute machine code, so programs written in high-level languages must be translated. A compiler translates the whole program into machine code before it runs (as in C), producing an executable file. An interpreter translates and executes the program step by step while it runs. Python is usually described as an interpreted language: the standard interpreter (CPython) first compiles source code into an intermediate bytecode and then executes that bytecode on the Python Virtual Machine.

Key terms

Interpreter
translates and runs code statement by statement
Compiler
translates the whole program before running
Bytecode
intermediate code executed by the Python Virtual Machine
Interactive mode (REPL)
read–evaluate–print loop with the >>> prompt
Script mode
running a saved .py file
IDE
integrated development environment
Traceback
error report showing where an error happened
All Grade 12 Information Technology key terms →

Summary

  • An interpreter runs code step by step; a compiler translates it all first.
  • CPython compiles to bytecode, then runs it on a virtual machine.
  • Interactive mode (>>>) for quick tests; script mode for saved programs.
  • Tracebacks report errors with line numbers.

In everyday life: Python runs on cheap Android phones through free apps, so Ethiopian students without a computer can still practise programming.

Check yourself

  • Give one advantage and one disadvantage of interpreted languages.
  • What does the >>> prompt mean?
  • How do you run a script called marks.py from the command line?

Practice questions

  1. 1. True or false: In interactive mode, the Python interpreter runs each statement as soon as you press Enter.

    Show answer

    Answer: True

    Interactive mode (the >>> shell, or REPL) reads, evaluates and prints the result of each statement immediately.

On WeLearn

The full lesson: reading notes, worked examples, class activities and the Unit 6 quiz

Study The Python Interpreter on WeLearn

Teach The Python Interpreter with WeLearn

We will bring a demo to your school: a lesson on your interactive TV, a virtual lab and a classroom game, with your own teachers.