0) Notebook basics (must know)
- Run cell:
Shift + Enter - Run and insert new cell below:
Alt + Enter - Command mode vs Edit mode:
Esc(command),Enter(edit) - Add cell below/above:
B/A(command mode) - Change cell type:
M(Markdown),Y(Code) - Delete cell:
DD(press D twice) - Move cell:
J/Kselect thenCtrl + Shift + ↑/↓(or cut/paste)
A) Python essentials inside Notebook (1–15)
1) Confirm Python environment
import sys, platform
print(sys.version)
print(platform.platform())
print(sys.executable)
2) Install a package (inside notebook)
%pip install requests
3) Check installed packages quickly
%pip list
4) See current working folder
import os
os.getcwd()
5) List files
import os
os.listdir(".")
6) Create folders safely
from pathlib import Path
Path("data").mkdir(exist_ok=True)
7) Read a text file
from pathlib import Path
Path("sample.txt").write_text("hello jupyter\nline2")
print(Path("sample.txt").read_text())
8) Timing a single line
%time sum(range(10_000_00))
9) Timing a whole cell
%%time
total = 0
for i in range(2_000_000):
total += i
total
10) Measure memory (if installed)
%pip install memory_profiler
%load_ext memory_profiler
%memit [i*i for i in range(300_000)]
11) Quick help for any function
len?
12) Docstring + signature
help(str.split)
13) Pretty print complex objects
from pprint import pprint
pprint({"a":[1,2,3], "b":{"x":10,"y":20}})
14) Rich display (HTML)
from IPython.display import HTML
HTML("<h3 style='color:green'>Hello from HTML</h3>")
15) Display Markdown from code
from IPython.display import Markdown
Markdown("### This is generated **Markdown** from Python")
B) Markdown mastery (16–22)
16) Markdown template (copy into a Markdown cell)
# Title
## Section
- bullet
- bullet
**bold**, *italic*, `inline code`
> blockquote
[link text](https://example.com)
17) Tables in Markdown
| Name | Score |
|------|------:|
| Raj | 98 |
| Asha | 87 |
18) LaTeX math (Markdown cell)
Inline: $E=mc^2$
Block:
$$
\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
$$
19) Collapsible sections (Markdown cell)
<details>
<summary>Click to expand</summary>
Hidden details here.
</details>
20) Add images from file (Markdown cell)

21) Add emojis ✅🔥📌
Learning Jupyter is fun ✅🔥
22) Use “TOC” style headings (habit tip)
Use consistent headings: #, ##, ### so notebooks stay readable.
C) Data analysis superpowers (23–35)
23) Install core data stack
%pip install numpy pandas matplotlib
24) Make a DataFrame
import pandas as pd
df = pd.DataFrame({"name":["A","B","C"], "score":[88,92,79]})
df
25) Filter rows
df[df["score"] >= 90]
26) Describe statistics
df["score"].describe()
27) Add a new column
df["passed"] = df["score"] >= 80
df
28) Save to CSV
df.to_csv("scores.csv", index=False)
29) Load from CSV
pd.read_csv("scores.csv")
30) Basic plot
import matplotlib.pyplot as plt
df.plot(kind="bar", x="name", y="score")
plt.show()
31) Histogram
df["score"].plot(kind="hist", bins=5)
plt.show()
32) Read JSON
import json
data = {"users":[{"name":"A","age":30},{"name":"B","age":26}]}
Path("users.json").write_text(json.dumps(data))
pd.json_normalize(json.loads(Path("users.json").read_text())["users"])
33) Quick pivot
sales = pd.DataFrame({
"city":["Tokyo","Tokyo","Osaka","Osaka"],
"product":["A","B","A","B"],
"amount":[10,14,8,11]
})
sales.pivot(index="city", columns="product", values="amount")
34) Groupby
sales.groupby("city")["amount"].sum()
35) Missing values
import numpy as np
d = pd.DataFrame({"a":[1, None, 3]})
d.isna()
D) Notebook “magic commands” (36–44)
36) Run a shell command
!ls -la
37) Current directory (shell)
!pwd
38) Download a file (example)
# Example only: works if your environment has internet access
# !curl -L -o sample.txt https://example.com/file.txt
39) Auto-reload code you edit in .py files
%load_ext autoreload
%autoreload 2
40) Save a cell into a Python file
%%writefile my_utils.py
def add(a,b):
return a+b
41) Import from your saved file
import my_utils
my_utils.add(2, 5)
42) Debug in notebook (simple)
def f(x):
return 10 / x
# f(0) # uncomment to see error
43) Launch debugger (Python 3.7+)
import pdb
# pdb.set_trace() # set breakpoint and run cell
44) Capture output of a cell
%%capture cap
print("hello")
print("captured")
cap.stdout
E) Visualization + rich outputs (45–50)
45) Show an image (local file)
from IPython.display import Image
# Image("path/to/image.png")
46) Display multiple outputs cleanly
from IPython.display import display
display(df.head())
display(df.describe())
47) Progress bar
%pip install tqdm
from tqdm import tqdm
for _ in tqdm(range(20000)):
pass
48) Interactive widgets (sliders/buttons)
%pip install ipywidgets
import ipywidgets as widgets
widgets.IntSlider(value=5, min=0, max=10)
49) Simple interactive function
import ipywidgets as widgets
from IPython.display import display
def show_square(x):
print("square =", x*x)
slider = widgets.IntSlider(value=3, min=0, max=20)
widgets.interactive(show_square, x=slider)
50) Export notebook tips
- From UI: File → Save and Export Notebook As → HTML / PDF
- Keep notebooks clean by: Restart Kernel & Run All before sharing.
🔥 15 “Pro Tips” that make you fast in Jupyter
- Create a top cell called “Setup” (imports, config, paths).
- Use Markdown headings to structure like a mini-book.
- Name notebooks:
2026-02-14-topic-v1.ipynbfor versioning. - When you get weird errors: Kernel → Restart.
- Use
%pip install ...inside notebook (avoids wrong pip). - Always print
sys.executableif packages behave oddly. - Keep data in
/datafolder, code in/srcfolder. - Use
%%timebefore optimization—don’t guess. - Keep cells small; one idea per cell.
- Avoid hidden state: run Restart & Run All regularly.
- Use
display()for multiple outputs (better than print). - Use
autoreloadwhen building utilities. - Use
tqdmfor long loops so you know it’s not stuck. - Don’t store secrets in notebooks; use env vars.
- Export to HTML for sharing—looks professional.