Course map
Stage 1: Foundation
Stage 2: Intermediate
Stage 3: Advanced
Stage 4: DSA in Python
Stage 5: Specialization

Part 01 / Topic 4 of 7

REPL vs script

There are two ways to run Python. Both need a terminal: a window where you type commands (Command Prompt / PowerShell on Windows, Terminal on macOS / Linux).

Terminal basics: the terminal always works "inside" one folder. Move to the folder that has your file before you run it.

Command What it does
cd python-practice Go into the folder python-practice (cd = change directory)
cd .. Go up one folder
ls (macOS / Linux) · dir (Windows) List the files in this folder

Don't want to type commands? In VS Code you can also press ▶️ Run Python File; it opens a terminal and runs the file for you.

python or python3? On Windows type python (or py). On macOS / Linux type python3. This course writes python; use the one that works on your computer.

  • REPL (Read–Eval–Print Loop): type python (or python3) in a terminal. You type one line, Python runs it at once. Good for quick tests.
  • Script: save code in a .py file and run python hello.py. Good for real programs you want to keep.

Real-world example: Check 250 * 12 in the REPL quickly; write a full salary calculator in a script.

$ python
>>> 250 * 12
3000
>>> name = "Asha"
>>> name.upper()
'ASHA'
>>> exit()
# hello.py → run with: python hello.py
print("Hello, World!")
print("Welcome to Python Step by Step")
# Output:
# Hello, World!
# Welcome to Python Step by Step
REPL Script (.py file)
Start python python hello.py
Shows values automatically Yes (>>> 2+2 shows 4) No, you must use print()
Code is saved No Yes
Best for Quick experiments Real programs
Exit exit() or Ctrl+D (Ctrl+Z Enter on Windows) Ends at the last line

🔍 Going deeper: Python 3.13 has a new REPL with colours, multi-line editing and exit without brackets. python -i hello.py runs a script and then drops you into the REPL with its variables still loaded, which is handy for poking at results.

🧪 Quick quiz — answer from memory, then check.

  1. You want to test 250 * 12 quickly — REPL or script?
  2. In the REPL, do you need print() to see the value of 2 + 2?
  3. How do you leave the REPL?
Show the answers
  1. REPL — one line, instant answer.
  2. No. The REPL shows values automatically; in a script you need print().
  3. exit() or Ctrl+D (Windows: Ctrl+Z then Enter).

Done here? The practice set for Part 1 — 6 exercises with solutions — is on the part page.

Search the guide