HomeCourseModule 01 › How Python actually runs

How Python actually runs

Module 01 · Introduction to Python7 min readBeginner

What you'll learn

  • Describe what happens when you 'run' Python code
  • Identify the three main places code gets run (REPL, script, notebook)
  • Pick the right one for a given situation

What 'running' Python means

When you write Python code, it's just plain text in a file. The computer can't do anything with text on its own. To make it do something, you hand the text to a program called the Python interpreter. The interpreter reads the text from top to bottom, one line at a time, and acts on each instruction as it gets to it.

Two consequences worth knowing:

The three places you'll run code

1. The REPL — for trying things

REPL stands for Read–Eval–Print Loop. It's an interactive prompt: you type one line, hit Enter, and Python answers immediately. Great for experimenting.

>>> 2 + 2
4
>>> "hello".upper()
'HELLO'

You'll meet the REPL in Module 2.

2. A script — for things you want to run again

A script is a file ending in .py that holds Python code. You write the code once, save the file, and you can run it whenever you want, as many times as you want.

# clean_monday_report.py
import pandas as pd
df = pd.read_excel("monday_raw.xlsx")
df = df.dropna()
df.to_excel("monday_clean.xlsx", index=False)
print("Done.")

This is what 90% of "automating boring stuff" looks like.

3. A notebook — for analysis

A Jupyter notebook (file extension .ipynb) is somewhere between a script and a Word document. You write code in little blocks called cells, and the output appears right below each cell. You can mix code, charts, and notes in the same document.

Notebooks are the standard format for data analysis — you'll see them everywhere in finance, science, and business analytics.

📝 And one more: =PY() inside Excel
A fourth place Python now runs is inside an Excel cell itself, via the new =PY() formula. The code runs on a server in the cloud and the result lands back in the cell. We cover this in Module 8.

Which should I use when?

SituationUse
"What does this single line do?"REPL
"I want to run this same job every Monday."Script (.py)
"I'm exploring data and want notes alongside."Notebook (.ipynb)
"I want a Python value inside a spreadsheet cell."=PY() in Excel

You don't have to install anything to try this

If you want a taste before Module 2, you can run Python in a browser tab right now — try online-python.com or replit.com.

Key takeaways

  • "Running" Python means handing your code to the interpreter, which reads it top-to-bottom.
  • The REPL is for trying single lines. Scripts are for repeatable jobs. Notebooks are for analysis with notes.
  • =PY() is a fourth option that runs Python inside an Excel cell.
  • You can try all of this in a browser before you install anything.

Try it now (browser only, no install)

  1. Open online-python.com.
  2. Paste this code and hit Run:
    name = "your name here"
    print("Hi, " + name + "!")
    print("Today's Python lesson is going well.")
  3. Change "your name here" to your actual name, and run it again.
  4. You just used a variable, a function, and string addition — three of Python's most-used features.
📹 Video walkthrough
A video walkthrough of this lesson will be embedded here. Until then, the written walkthrough above mirrors what the video will cover step-for-step.