Jupyter Notebook — Introduction
Jupyter Notebook — Introduction
Section titled “Jupyter Notebook — Introduction”What is Jupyter Notebook?
Section titled “What is Jupyter Notebook?”Jupyter Notebook is an open-source, browser-based interactive computing environment that lets you create documents combining live code, equations, visualizations, and narrative text. The name comes from the three core languages it originally supported: Julia, Python, and R.
It is the standard tool for:
- Data exploration and analysis
- Machine learning experimentation
- Scientific computing
- Teaching and documentation
- Reproducible research
How It Works
Section titled “How It Works”A notebook is a .ipynb file (JSON format) containing a sequence of cells. The Jupyter server runs a kernel — a separate process that executes code. The browser communicates with the kernel via WebSockets.
Browser (UI) ←→ Jupyter Server ←→ Kernel (Python/R/Julia process)Cell Types
Section titled “Cell Types”| Type | Purpose |
|---|---|
| Code | Executable code (Python, R, etc.) |
| Markdown | Formatted text, headings, lists, math |
| Raw | Unformatted text, not executed |
Installation
Section titled “Installation”# Via pippip install notebook # Classic Jupyter Notebookpip install jupyterlab # JupyterLab (modern UI)
# Via condaconda install -c conda-forge notebookconda install -c conda-forge jupyterlab
# Launchjupyter notebook # opens at http://localhost:8888jupyter lab # opens JupyterLabJupyterLab vs Classic Notebook
Section titled “JupyterLab vs Classic Notebook”| Feature | Classic Notebook | JupyterLab |
|---|---|---|
| UI | Single document | Full IDE-like |
| Multiple tabs | No | Yes |
| File browser | Basic | Full |
| Extensions | Limited | Rich ecosystem |
| Terminal | No | Yes |
| Recommended | Legacy | Yes (current standard) |
Key Concepts
Section titled “Key Concepts”- Kernel: The computational engine. Each notebook connects to one kernel. You can restart, interrupt, or change the kernel.
- Cell execution order: Cells can be run in any order — the kernel maintains state. This is a common source of bugs.
- Output: Displayed inline below each cell — text, tables, plots, HTML, widgets.
.ipynbformat: JSON file storing cell content, outputs, and metadata.
First Notebook
Section titled “First Notebook”# Cell 1 — importsimport numpy as npimport matplotlib.pyplot as plt
# Cell 2 — computationx = np.linspace(0, 2 * np.pi, 100)y = np.sin(x)
# Cell 3 — visualizationplt.plot(x, y)plt.title("Sine Wave")plt.xlabel("x")plt.ylabel("sin(x)")plt.show()Keyboard Shortcuts
Section titled “Keyboard Shortcuts”| Shortcut | Action |
|---|---|
Shift+Enter | Run cell, move to next |
Ctrl+Enter | Run cell, stay |
Alt+Enter | Run cell, insert below |
Esc | Command mode |
Enter | Edit mode |
A (command) | Insert cell above |
B (command) | Insert cell below |
DD (command) | Delete cell |
M (command) | Change to Markdown |
Y (command) | Change to Code |
00 (command) | Restart kernel |