Foundations of Programming (Python)

IT Fundamentals· 3 CUs· E010
Objective assessmentDue Apr 28, 2027
Running Python in different environments

Interpreter, REPL and scripts

10 min

The interpreter (CPython, from python.org) reads Python code and runs it. It checks the whole file for syntax first, then runs statements top to bottom.

ModeStartShows output
Interactive (REPL)python or py (Windows), python3 (macOS, Linux); prompt >>>The value of every expression typed
ScriptSave as .py, run python file.pyOnly what print() writes
text
>>> 7 * 6
42
>>> "ada".upper()
'ADA'
>>> exit()
python
# calc.py
7 * 6          # computed, then discarded: no output
print(7 * 6)   # 42

A bare expression prints in the REPL, not in a script. A script that runs without errors and shows nothing is usually missing print().

  • Python 3 only. Python 2 ended January 1, 2020; print "hi" without parentheses is Python 2.
  • Current release (November 2026): 3.15. Check with python --version.
Interpreter
Program that runs Python code. CPython is the standard one.
REPL
Read, evaluate, print, loop: the >>> prompt.
Script
A .py file run as a whole.

Knowledge check

At >>> you type total = 5 + 3, then total. What appears?

A script has a syntax error on line 40. What runs?