Jupyter Notebooks for Data Science
Launch Jupyter, write cells, use magic commands, and export notebooks.
Jupyter Notebooks for Data Science is a free Learn AI with Python lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Learn AI with Python learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Notebooks for Exploration
A Jupyter notebook mixes code, output, plots, and prose in one document. You run code in small cells, keeping state between them, which is ideal for iterative data exploration.
Notebook vs Lab
Jupyter Notebook is the classic single-document interface. JupyterLab is the modern IDE-like interface with a file browser, tabs, and multiple panels. Both run the same .ipynb files.
pip install jupyterlab notebook
jupyter lab # modern interface
jupyter notebook # classic interfaceCell Types
Cells are either Code (executed by the kernel) or Markdown (rendered as formatted text for explanations). Switch a cell to Markdown with the M key, back to Code with Y.
# Code cell
import numpy as np
np.arange(5)
# Markdown cell (rendered):
# ## Section title
# Some **bold** explanation.Run and Output
Press Shift+Enter to run a cell and move to the next. The value of the last expression is displayed automatically, no print needed.
x = 2 + 2
x # displays 4 below the cellTiming with %timeit
The %timeit line magic runs a statement many times and reports the average. It is the standard way to compare implementations.
%timeit sum(range(1000))
# 1000 loops, best of 5: 12.3 us per loopCell-wide Timing
Double the percent sign for a cell magic. %%timeit times the entire cell rather than a single line.
%%timeit
total = 0
for i in range(1000):
total += iInline Plots
%matplotlib inline tells Jupyter to render plots directly under the cell as static images. Set it once near the top of the notebook.
%matplotlib inline
import matplotlib.pyplot as plt
plt.plot([1, 4, 9, 16])Shell Commands in Cells
Prefix a line with ! to run a shell command. Handy for checking versions or listing files without leaving the notebook.
!pip install seaborn
!ls -la
!python --versionCapturing Shell Output
You can assign shell output to a Python variable. The result is a list of output lines.
files = !ls *.csv
print(len(files), "CSV files found")Kernel: Restart and Run All
Out-of-order execution can hide bugs. Kernel → Restart and Run All clears all state and re-runs every cell top to bottom, proving your notebook is reproducible.
Listing Defined Names
The %who magic lists variables defined in the session, useful after long exploration to see what is in memory.
%who
# files np plt xQuick Check
Check your notebook fundamentals.
Recap
You can now work effectively in notebooks:
- Notebook (classic) vs Lab (IDE-like) share
.ipynb - Code vs Markdown cell types
%timeit/%%timeitfor benchmarking%matplotlib inlinefor plots!cmdfor shell commands- Restart and Run All for reproducibility,
%whoto inspect state
Frequently asked questions
Is the “Jupyter Notebooks for Data Science” lesson free?
Yes — the full text of “Jupyter Notebooks for Data Science” is free to read here on the web, and the Learn AI with Python course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Learn AI with Python course, upgrade to CoddyKit PRO.
What will I learn in “Jupyter Notebooks for Data Science”?
Launch Jupyter, write cells, use magic commands, and export notebooks. You practise Learn AI with Python with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Learn AI with Python?
No prior experience is required. Learn AI with Python on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Jupyter Notebooks for Data Science” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Learn AI with Python lesson?
Yes. Every Learn AI with Python lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Virtual Environments and pip
- Jupyter Notebooks for Data Science
- Python Data Types for Data Science
- Working with the Python REPL and IPython