Jupyter Notebook
Last updated on 2026-03-04 | Edit this page
Estimated time: 45 minutes
Introduction to Jupyter Notebooks
A Beginner’s Guide for New Data Scientists (Python)
1. What Is a Jupyter Notebook?
A Jupyter Notebook is an interactive computing environment that allows you to combine:
- Code (Python)
- Text explanations
- Mathematical equations
- Tables and visualizations
- Results and outputs
All in a single document.
Jupyter Notebooks are especially useful for:
- Data exploration and analysis
- Teaching and learning Python
- Prototyping models
- Sharing reproducible research
Instead of writing a script and running it all at once, you work in small, executable blocks called cells.
2. Why Data Scientists Use Jupyter Notebooks
Jupyter Notebooks support an iterative workflow:
- Write a few lines of code
- Run them immediately
- Inspect the output
- Modify and rerun as needed
3. Getting Started: Opening a Notebook
You can use Jupyter Notebooks in several ways:
Through Anaconda Navigator. Install the application, create an account, and launch Jupyter Notebook.
Through Google Collab. You would need a google account for this. Then create a new notebook in Drive.
Quick Start in Google Colab (easiest for beginners)
- Go to https://colab.research.google.com
- Click File → New notebook
- You’re ready! No installation needed.
Colab runs in the cloud → you only need a Google account and internet.
Tip: The interface looks almost identical to classic Jupyter.
4. Understanding Cells
A Jupyter Notebook is composed of cells. Each cell performs a specific role.
5. Running Cells
You can execute cells using keyboard shortcuts:
Shift + Enter→ Run cell and move to nextCtrl + Enter→ Run cell and stay in placeAlt + Enter→ Run cell and insert a new one below
Important: Cells do not need to be run from top to bottom, but execution order matters.
6. The Notebook Kernel
The kernel is the computational engine that runs your code.
For Python notebooks, the kernel:
Executes Python code
Stores variables in memory
Can be restarted or interrupted
7. Variables and Statefulness – The Most Important Concept
Jupyter remembers variables across cells as long as the kernel is running.
This is very powerful… but also the source of most beginner frustration.
Demo – run these cells one by one
Cell A
Cell B
Cell C
Challenge
Challenge — Variable Values State
- Create 3 new code cells
- In cell 1:
count = 0 - In cell 2:
count = count + 1; print(count) - In cell 3:
print("Final count:", count) - Run all → should print 1
- Now run only cell 2 five times
- Run cell 3 again → what happened?
→ You just experienced statefulness live!
8. Working with Data in Jupyter
Most data science workflows start by importing libraries and loading data.
9. Visualization Inside Notebooks
Plots are displayed inline, directly below the code cell.
Example:
PYTHON
plt.plot([1, 2, 3, 4], [10, 20, 25, 30])
plt.xlabel("X values")
plt.ylabel("Y values")
plt.title("Simple Line Plot")
plt.show()
This makes exploratory analysis fast and interactive.
10. Using Markdown for Documentation
Well-written notebooks tell a story.
Use Markdown cells to:
- Explain your approach
- Describe datasets
- Interpret results
- Organize sections
11. Common Beginner Mistakes & How to Avoid Them
Running cells out of order
→ Variables get unexpected values
Fix: Kernel → Restart & Run All oftenForgetting to import libraries in a fresh kernel
→ “NameError: name ‘pd’ is not defined”
Fix: Put allimportstatements in the first code cellOne giant code cell with 200 lines
→ Hard to debug, hard to fix mistakes
Fix: Break logic into small cells (one logical step per cell)No Markdown explanations
→ Nobody (including future you) understands what you did
Fix: Add a Markdown cell before/after important code blocksSharing notebook without restarting & running all
→ Collaborator sees missing variables or wrong results
Fix: Always do Kernel → Restart & Run All before sharing/exportingAssuming outputs are permanent
→ Outputs disappear on kernel restart
Fix: Rely on code, not on saved output images
Module Overview
| Lesson | Overview |
|---|---|
| Introduction I | Introduction to Variable Handling in Jupyter Notebook |
| Introduction II | Introduction to Python Coding in Jupyter Notebook |
| Introduction III | Introduction to Python Plotting in Jupyter Notebook |