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 |