Interactive Mode vs Script Mode in Python
Interactive mode (the Python REPL) runs code line by line and automatically shows the value of any expression you type. Script mode runs a whole .py file at once and stays silent unless you explicitly print() something.
Type miles * 1.61 in one place and Python shows you the answer instantly. Paste the exact same line into a .py file, run it, and... nothing. No error, no output, silence. That is not a bug — it is the difference between interactive mode and script mode, and mixing them up is one of the first beginner traps in Python.
This page shows exactly what changes between the two, why script mode looks broken until you add print(), and how to open each mode on your machine. Pair it with Statements vs Expressions for why expressions auto-display in one mode but not the other.
What you will learn
By the end you can:
- Explain the difference between Python's interactive mode and script mode
- Know why expressions auto-print in one mode but stay silent in the other
- Open the interactive interpreter (REPL) from your terminal
- Write and run a
.pyscript correctly - Avoid the classic 'why is nothing printing' confusion
Interactive mode — a conversation
Interactive mode is a live chat with Python. You type a line, Python replies immediately. It is often called the REPL (read–eval–print loop).
>>> miles = 26.2
>>> miles * 1.61
42.182Look closely at what happened: the first line is an assignment — no visible output. The second line is an expression — Python evaluates it and displays the result automatically. In interactive mode, typing a bare expression is enough to see its value; it feels like using Python as a calculator.
Script mode — a written letter
Now put the same two lines into a file:
miles = 26.2
miles * 1.61Run that file. Nothing appears — no error, no output, silence. That is expected: in script mode, expressions do not display their result automatically. Python still evaluates them, but it only shows output when you explicitly ask for it.
miles = 26.2
print(miles * 1.61)
# 42.182How to open each mode
Interactive mode: open the Command Prompt (Windows) or Terminal (macOS/Linux), type python (or python3), and press Enter. A >>> prompt appears, letting you run commands one at a time.
Script mode: open any text editor or IDE (VS Code, IDLE, PyCharm), write your code in a file ending in .py, save it, then run the file — for example python my_script.py — to execute the entire program at once.
When to use which
| Situation | Best mode |
|---|---|
| Testing a quick idea or formula | Interactive mode |
| Exploring what a function returns | Interactive mode |
| Building a real, reusable program | Script mode |
| Something teammates or a server will run repeatedly | Script mode |
Common mistakes
- Writing a script, expecting bare expressions to print like the REPL does
- Assuming a silent script means it crashed — it may have run fine with no
print() - Copy-pasting
>>>prompts into a.pyfile (syntax error — the prompt itself is not code) - Forgetting that variables set in one interactive session disappear when you close it
Why this matters
Every Python programmer lives in both worlds: the REPL for fast experiments, scripts for anything that needs to run more than once. Knowing which mode you are in — and that script mode stays silent unless told otherwise — removes a whole category of "my code isn't working" confusion before it starts.
Common questions
What is the difference between interactive mode and script mode in Python?
Interactive mode (the REPL) runs code one line at a time and automatically displays the value of any expression. Script mode runs an entire .py file at once and only shows output when you explicitly call print().
Why does my Python script show no output?
In script mode, bare expressions do not auto-display like they do in interactive mode. If a line just computes a value without printing it, nothing appears. Add print() around the value you want to see.
How do I start Python's interactive mode?
Open a terminal or command prompt and type python (or python3), then press Enter. The >>> prompt appears, letting you run one line of code at a time.
How do I run a Python script?
Save your code in a file ending in .py, then run it from the terminal with a command like python filename.py.
Is the Python REPL the same as interactive mode?
Yes. REPL stands for read-eval-print loop, which describes exactly what interactive mode does: read your input, evaluate it, print the result, and loop back for more.
Explore
Related topics
Keep going — these sit next to this concept in a real learning path.
Statements vs Expressions in Python
Why expressions produce values that interactive mode shows automatically.
Programs, Interpreters & Compilers in Python
How Python actually runs the code you write.
Variables in Python
Assignments look silent in both modes — here's why.
Order of Operations in Python
Try precedence examples live in interactive mode.
The input() Function in Python
Reading user input and converting it from a string to a number.
Python course hub
All free Python explainers and the path into Agentic practice.