Skip to main content
This lesson explains what Jupyter Notebooks solve, why data scientists favor them for experimentation and collaboration, how to run them (hosted services or locally), and their primary benefits. The dominant language for data science is Python. To develop models and analyze data you need an appropriate Python environment. Several options exist, each with trade-offs depending on whether your goal is quick experimentation, reproducible analysis, or production-quality development.

Problem: Python REPL (interactive shell)

A minimal starting point is the Python interactive shell (a REPL — Read, Evaluate, Print Loop). If Python is installed locally, running python opens a prompt where you can try commands like print("hello") and get immediate results. This is great for quick experiments and learning, but it doesn’t scale for multiline, reusable, or version-controlled code. For moderate-length scripts (tens or hundreds of lines) you typically use Python script files and an editor or IDE instead.
A presentation slide titled "Problem: Need Python Environment" showing the Python logo and the label "Python shell — Read, Evaluation, Print Loop." The slide notes the shell runs commands and shows results instantly, is good for quick tests but not for saving code, and recommends Python scripts for reusable code.

Alternatives: IDEs

Integrated development environments (IDEs) supply many productivity features that help when building applications:
  • Code completion and parameter hints
  • Syntax highlighting and linting
  • Debugging (breakpoints, step over/into, variable watches)
  • AI-assisted suggestions in some editors
Popular IDEs include Visual Studio Code, IDLE, and PyCharm. IDEs are excellent for production applications (Flask, Django) and for advanced debugging, but they do not always match the exploratory, iterative needs of data analysis.
A presentation slide titled "Problem: Need Python Environment" showing logos for VS Code, Python IDLE, and IntelliJ PyCharm. To the right are three points: code assistance, debugging tools, and an efficiency boost for faster development.

Why data scientists need something different

Data exploration typically requires multiple tools and rich visualizations to understand feature distributions and correlations. Libraries such as Matplotlib and Seaborn are commonly used to create charts that drive feature engineering and model design. REPLs and traditional IDEs can be limiting for reproducibility and collaborative experiments. To let colleagues reproduce your analysis or inspect “how you got that result,” you need an environment that preserves code, outputs (including charts), and narrative explanation together.
A presentation slide titled "Problem: Need Python Environment" showing three numbered panels that say: data exploration requires multiple Python tools; visualization and annotation help document findings; and REPLs/IDEs are not enough for reproducibility.

Solution: Jupyter Notebooks

Jupyter Notebooks are an interactive, web-based environment designed for experimentation and sharing. Key features:
  • Code organized into cells so you can run small chunks independently.
  • Inline outputs: text, tables, and visualizations display directly below code cells.
  • Persistence of inputs and outputs for reproducible experiments.
  • Markdown cells let you add narrative, headings, and LaTeX math for clear documentation.
This combination of executable code, visual output, and descriptive text supports scientific-style workflows: state a hypothesis, run experiments, visualize results, iterate, and document findings.
A presentation slide titled "Solution: Jupyter Notebooks" showing the Jupyter logo on the left and three brief points on the right: code runs in chunks ("cells"), it's interactive/REPL-like with saved inputs/outputs, and a persistent interface that keeps code, results, and experiments.

Notebook structure and cells

Notebooks contain two primary cell types:
  • Code cells: execute Python and display standard output inline. Visualizations from Matplotlib or Seaborn are rendered directly and saved with the notebook.
  • Markdown cells: document steps, reasoning, and include LaTeX-compatible math.
Run cells interactively (for example, Shift+Enter). Each execution yields an execution count (e.g., In [1], In [2]) that reflects the order cells were run. Re-run cells as you iterate to update outputs.
A slide titled "Solution: Jupyter Notebooks" showing a boxed diagram of stacked colored blocks illustrating the Jupyter Notebook cell execution process. The blocks are labeled Python Code, Standard Console Output, Markdown Code including LaTeX, and Standard Console Output including charts.

Example — interactive notebook cells

A short example illustrating two code cells and their outputs. When executed in a notebook the printed results appear inline and are persisted with the .ipynb file.
# In [1]:
a = 10
b = 5
print(a + b)
# Output:
# In [2]:
prices = [500000, 600000, 650000, 44000, 127000]
for price in prices:
    print(f'Current price is {price}')
# Output:
# Current price is 500000
# Current price is 600000
# Current price is 650000
# Current price is 44000
# Current price is 127000

Comparison with other Python environments

Jupyter Notebooks combine interactive execution, inline visualization, and narrative markdown — making them ideal for data exploration, reproducibility, and teaching. REPLs are interactive but lack integrated visualization and reproducibility features; IDEs excel at debugging, code navigation, and production development, but are less naturally suited to exploratory, step-by-step scientific workflows.
A slide titled "Solution: Comparison of Python Environments" showing a table that compares features (interactive coding, data visualization, text+code mix, reproducibility, collaboration, kernel support, teaching, debugging) across Jupyter Notebook, Python Shell, and Python IDE (e.g., PyCharm). Each cell uses checkmarks, warning icons, and crosses to indicate strengths, limitations, or lack of support.
Use the table below to quickly compare environments by common use case:
Resource TypeBest forStrengths
Jupyter Notebook / JupyterLabExploratory data analysis, visualization, reproducible research, teachingInline plots, markdown + code, shareable .ipynb, easy iteration
Python REPL (interactive shell)Quick experiments, learningImmediate feedback, minimal overhead
Python IDE (VS Code, PyCharm)Production apps, debugging, refactoringAdvanced debugging, linting, project tooling, scalability

Jupyter vs JupyterLab

Two common interfaces:
  • Jupyter (classic): a simpler UI focused on one notebook at a time. Files use the .ipynb extension.
  • JupyterLab: a modern, extensible IDE-like multi-pane interface. Supports multiple open files, terminals, and many extensions (Git integration, linters, documentation tools, vendor plugins).
JupyterLab includes a built-in terminal so you can install packages directly into the running environment without leaving the browser.
A presentation slide titled "Solution: Jupyter Notebook vs Jupyter Lab" comparing the two tools. It shows two panels listing Jupyter's classic, single‑tab interface and JupyterLab's modern, multi‑pane, extensible IDE‑like workspace.

Example: install packages from a notebook-attached terminal

# Install visualization libraries in the notebook environment
pip install matplotlib seaborn

Files, version control, and collaboration

Notebooks are saved as .ipynb files that embed code cells, markdown cells, and the outputs produced by executed cells. For collaborative projects use version control (e.g., Git), but be mindful of large outputs and binary-encoded images included in notebooks.
Best practice: Use markdown cells to explain intent and decisions, keep notebooks modular (one experiment per notebook or clear sections), and clear heavy outputs before committing. Consider tools like nbstripout or nbdime to produce cleaner diffs and reduce repository noise.
Warning: Never commit notebooks that contain secrets or credentials. Also avoid large binary outputs (heavy plots, full datasets); store data externally and load it at runtime to keep repositories lightweight.

Summary

  • Jupyter Notebooks provide an interactive, web-based environment ideal for exploratory data analysis, visualization, and reproducible experiments.
  • They combine executable code, inline outputs (including charts), and rich markdown documentation to tell the story of your analysis.
  • Choose JupyterLab for a multi-pane, extensible, IDE-like experience with integrated terminal and plugin support.
  • Use traditional IDEs when you need advanced debugging, project organization, and production-ready development workflows.

Watch Video