Skip to content

Commit 6b3cdd6

Browse files
committed
Add Chapter 0: How to Use This Tutorial
Covers Jupyter basics (cells, Shift+Enter, kernel restart), saving work on Binder and Colab, and what to do when things go wrong. Updates intro page with Binder vs Colab guidance and note to start at Chapter 0.
1 parent 57d6f18 commit 6b3cdd6

3 files changed

Lines changed: 352 additions & 4 deletions

File tree

‎_toc.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
format: jb-book
22
root: intro
33
chapters:
4+
- file: notebooks/Chapter_00_How_to_Use_This_Tutorial
5+
title: "0. How to Use This Tutorial"
46
- file: notebooks/Chapter_01_Setup_and_First_Program
57
title: "1. Setup & First Program"
68
- file: notebooks/Chapter_02_Variables_and_Data_Types

‎intro.md‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,17 @@ Work through the chapters **in order**. Each chapter builds on the previous one.
2727

2828
Use the **rocket icon** (🚀) at the top of any chapter to open it as a live interactive notebook — no installation needed.
2929

30-
```{admonition} Two Ways to Run
30+
```{admonition} Two Ways to Run — Read Before You Start
3131
:class: tip
3232
33-
**Binder** — Click the Binder button. A live Python environment opens in your browser in about 2 minutes. No account needed.
33+
**Binder** — Full Jupyter Notebook interface. No account needed. Takes 2–3 minutes to start the first time. Your work is **not saved automatically** — download your notebook before closing (File → Download as → Notebook).
3434
35-
**Google Colab** — Click the Colab button. Opens instantly. Requires a Google account.
35+
**Google Colab** — Opens instantly. Requires a Google account. Save your own copy before starting (File → Save a copy in Drive), otherwise your work will be lost when you close the tab.
36+
```
37+
38+
```{admonition} New to Jupyter Notebooks?
39+
:class: note
40+
Start with **Chapter 0** — it teaches you how to run cells, what to do when something goes wrong, and how to save your work. Do not skip it.
3641
```
3742

3843
---
@@ -41,6 +46,7 @@ Use the **rocket icon** (🚀) at the top of any chapter to open it as a live in
4146

4247
| # | Title | Time |
4348
|---|-------|------|
49+
| [0](notebooks/Chapter_00_How_to_Use_This_Tutorial) | How to Use This Tutorial | 15 min |
4450
| [1](notebooks/Chapter_01_Setup_and_First_Program) | Setup & Your First Program | 30 min |
4551
| [2](notebooks/Chapter_02_Variables_and_Data_Types) | Variables & Data Types | 45 min |
4652
| [3](notebooks/Chapter_03_Conditions_and_Loops) | Conditions & Loops | 1 hour |
@@ -50,7 +56,7 @@ Use the **rocket icon** (🚀) at the top of any chapter to open it as a live in
5056
| [7](notebooks/Chapter_07_The_Dashboard) | The Dashboard | 45 min |
5157
| [8](notebooks/Chapter_08_Experiments) | Experiments | 1 hour |
5258

53-
**Total: ~8 hours of self-study**
59+
**Total: ~8.25 hours of self-study**
5460

5561
---
5662

Lines changed: 340 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,340 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Chapter 0 — How to Use This Tutorial\n",
8+
"\n",
9+
"**Time:** ~15 minutes \n",
10+
"**Goal:** Understand the tools you are using before writing any Python.\n",
11+
"\n",
12+
"Read this chapter completely before moving to Chapter 1.\n",
13+
"\n",
14+
"---"
15+
]
16+
},
17+
{
18+
"cell_type": "markdown",
19+
"metadata": {},
20+
"source": [
21+
"## 0.1 What is a Jupyter Notebook?\n",
22+
"\n",
23+
"A Jupyter Notebook is a document that mixes two things:\n",
24+
"- **Text** — explanations, instructions, examples (like what you are reading now)\n",
25+
"- **Code** — Python programs you can run directly in the browser\n",
26+
"\n",
27+
"Each block is called a **cell**. There are two types:\n",
28+
"\n",
29+
"| Cell Type | What it contains | Background colour |\n",
30+
"|---|---|---|\n",
31+
"| Markdown cell | Text, headings, tables | White |\n",
32+
"| Code cell | Python code | Light grey |\n",
33+
"\n",
34+
"The cell below is a **code cell**. You can see it has a grey background and a `[ ]` on the left side."
35+
]
36+
},
37+
{
38+
"cell_type": "code",
39+
"execution_count": null,
40+
"metadata": {},
41+
"outputs": [],
42+
"source": [
43+
"print(\"This is a code cell\")"
44+
]
45+
},
46+
{
47+
"cell_type": "markdown",
48+
"metadata": {},
49+
"source": [
50+
"## 0.2 How to Run a Cell\n",
51+
"\n",
52+
"To run a code cell:\n",
53+
"\n",
54+
"1. **Click on the cell** to select it (a blue or green border appears around it)\n",
55+
"2. Press **`Shift + Enter`** on your keyboard\n",
56+
"\n",
57+
"The output appears directly below the cell. The `[ ]` on the left changes to a number like `[1]` — this is the execution count.\n",
58+
"\n",
59+
"**Try it now.** Click the cell above and press `Shift + Enter`."
60+
]
61+
},
62+
{
63+
"cell_type": "markdown",
64+
"metadata": {},
65+
"source": [
66+
"### Other ways to run a cell\n",
67+
"\n",
68+
"| Action | How |\n",
69+
"|---|---|\n",
70+
"| Run cell and move to next | `Shift + Enter` ← use this most of the time |\n",
71+
"| Run cell and stay | `Ctrl + Enter` |\n",
72+
"| Run cell button | Click the ▶ button in the toolbar |\n",
73+
"\n",
74+
"Run the cell below:"
75+
]
76+
},
77+
{
78+
"cell_type": "code",
79+
"execution_count": null,
80+
"metadata": {},
81+
"outputs": [],
82+
"source": [
83+
"print(\"I ran this cell using Shift + Enter\")\n",
84+
"print(\"Output appears right here below the cell\")"
85+
]
86+
},
87+
{
88+
"cell_type": "markdown",
89+
"metadata": {},
90+
"source": [
91+
"## 0.3 The Output Area\n",
92+
"\n",
93+
"When a cell runs, whatever the code prints appears in the **output area** directly below it. Run the cell below and observe:"
94+
]
95+
},
96+
{
97+
"cell_type": "code",
98+
"execution_count": null,
99+
"metadata": {},
100+
"outputs": [],
101+
"source": [
102+
"print(\"Line 1\")\n",
103+
"print(\"Line 2\")\n",
104+
"print(\"Line 3\")"
105+
]
106+
},
107+
{
108+
"cell_type": "markdown",
109+
"metadata": {},
110+
"source": [
111+
"To **clear the output** of a cell: right-click the cell → **Clear Output**.\n",
112+
"\n",
113+
"To **clear all outputs** in the notebook: from the menu, **Kernel → Restart & Clear Output**."
114+
]
115+
},
116+
{
117+
"cell_type": "markdown",
118+
"metadata": {},
119+
"source": [
120+
"## 0.4 Editing a Cell\n",
121+
"\n",
122+
"You can edit any code cell. Click inside it, change the code, and run it again.\n",
123+
"\n",
124+
"Try changing the message in the cell below and running it:"
125+
]
126+
},
127+
{
128+
"cell_type": "code",
129+
"execution_count": null,
130+
"metadata": {},
131+
"outputs": [],
132+
"source": [
133+
"print(\"Change this message to your name and run the cell\")"
134+
]
135+
},
136+
{
137+
"cell_type": "markdown",
138+
"metadata": {},
139+
"source": [
140+
"## 0.5 Run Cells in Order\n",
141+
"\n",
142+
"**Important:** Always run cells from top to bottom, in order.\n",
143+
"\n",
144+
"Each cell can use variables and functions defined in cells above it. If you skip a cell or run them out of order, you will get errors.\n",
145+
"\n",
146+
"Example — run these two cells in order:"
147+
]
148+
},
149+
{
150+
"cell_type": "code",
151+
"execution_count": null,
152+
"metadata": {},
153+
"outputs": [],
154+
"source": [
155+
"# Cell 1 — defines a variable\n",
156+
"temperature = 32"
157+
]
158+
},
159+
{
160+
"cell_type": "code",
161+
"execution_count": null,
162+
"metadata": {},
163+
"outputs": [],
164+
"source": [
165+
"# Cell 2 — uses the variable from Cell 1\n",
166+
"print(f\"Temperature is {temperature}°C\") # works only if Cell 1 ran first"
167+
]
168+
},
169+
{
170+
"cell_type": "markdown",
171+
"metadata": {},
172+
"source": [
173+
"If you run Cell 2 without running Cell 1 first, you will see: \n",
174+
"`NameError: name 'temperature' is not defined`\n",
175+
"\n",
176+
"The fix: run Cell 1 first, then Cell 2."
177+
]
178+
},
179+
{
180+
"cell_type": "markdown",
181+
"metadata": {},
182+
"source": [
183+
"## 0.6 What to Do When Something Goes Wrong\n",
184+
"\n",
185+
"### The cell shows an error\n",
186+
"Read the last line of the error message — it tells you what went wrong. Fix the code and run the cell again.\n",
187+
"\n",
188+
"### The cell is stuck (the `[*]` never changes to a number)\n",
189+
"This means the code is still running or is stuck in a loop. To stop it: \n",
190+
"**Kernel → Interrupt** (or press the ■ stop button in the toolbar)\n",
191+
"\n",
192+
"### Everything seems broken / variables have wrong values\n",
193+
"Restart the kernel and run all cells from the top: \n",
194+
"**Kernel → Restart & Run All**\n",
195+
"\n",
196+
"This resets everything to a clean state."
197+
]
198+
},
199+
{
200+
"cell_type": "code",
201+
"execution_count": null,
202+
"metadata": {},
203+
"outputs": [],
204+
"source": [
205+
"# This cell has an error on purpose — read the error message\n",
206+
"print(\"This line works\")\n",
207+
"print(undefined_variable) # NameError — this variable was never defined"
208+
]
209+
},
210+
{
211+
"cell_type": "markdown",
212+
"metadata": {},
213+
"source": [
214+
"The error says `NameError: name 'undefined_variable' is not defined`. Fix it by replacing `undefined_variable` with a string in quotes, then run again."
215+
]
216+
},
217+
{
218+
"cell_type": "markdown",
219+
"metadata": {},
220+
"source": [
221+
"## 0.7 The Toolbar\n",
222+
"\n",
223+
"The toolbar at the top of the notebook has the most common actions:\n",
224+
"\n",
225+
"| Button | What it does |\n",
226+
"|---|---|\n",
227+
"| 💾 (floppy disk) | Save the notebook |\n",
228+
"| + | Add a new cell below |\n",
229+
"| ✂️ | Cut the selected cell |\n",
230+
"| ▶ Run | Run the selected cell |\n",
231+
"| ■ Stop | Stop a running cell |\n",
232+
"| ⟳ Restart | Restart the kernel (clears all variables) |\n",
233+
"| ⏩ Run All | Restart and run every cell from top to bottom |\n",
234+
"\n",
235+
"You will use **▶ Run**, **■ Stop**, and **⟳ Restart** most often."
236+
]
237+
},
238+
{
239+
"cell_type": "markdown",
240+
"metadata": {},
241+
"source": [
242+
"## 0.8 Saving Your Work\n",
243+
"\n",
244+
"This is the most important section if you are using **Binder** or **Colab**.\n",
245+
"\n",
246+
"---\n",
247+
"\n",
248+
"### If you are using Binder\n",
249+
"\n",
250+
"```{warning}\n",
251+
"Binder does NOT save your work automatically. If you close the tab or the session times out (after ~10 minutes of inactivity), everything you typed is lost.\n",
252+
"```\n",
253+
"\n",
254+
"**To save your work before closing:**\n",
255+
"\n",
256+
"1. From the menu: **File → Download as → Notebook (.ipynb)**\n",
257+
"2. Save the downloaded file to your computer\n",
258+
"3. Next time you open Binder, upload the file: **File → Open** → drag and drop your saved file\n",
259+
"\n",
260+
"**Do this at the end of every study session.**\n",
261+
"\n",
262+
"---\n",
263+
"\n",
264+
"### If you are using Google Colab\n",
265+
"\n",
266+
"```{warning}\n",
267+
"Colab opens a temporary copy of the notebook. Changes are NOT saved back to GitHub.\n",
268+
"```\n",
269+
"\n",
270+
"**To save your own copy before you start:**\n",
271+
"\n",
272+
"1. From the menu: **File → Save a copy in Drive**\n",
273+
"2. A copy opens in your Google Drive — work from that copy\n",
274+
"3. Colab auto-saves to your Drive from that point on\n",
275+
"\n",
276+
"**Do this as soon as you open a chapter in Colab.**"
277+
]
278+
},
279+
{
280+
"cell_type": "markdown",
281+
"metadata": {},
282+
"source": [
283+
"## 0.9 Quick Reference\n",
284+
"\n",
285+
"| Task | Action |\n",
286+
"|---|---|\n",
287+
"| Run a cell | Click the cell → `Shift + Enter` |\n",
288+
"| Stop a stuck cell | Kernel → Interrupt |\n",
289+
"| Fix broken state | Kernel → Restart & Run All |\n",
290+
"| Save work (Binder) | File → Download as → Notebook (.ipynb) |\n",
291+
"| Save work (Colab) | File → Save a copy in Drive |\n",
292+
"| Add a new cell | Click + in toolbar |\n",
293+
"| Delete a cell | Select cell → Edit → Delete Cells |"
294+
]
295+
},
296+
{
297+
"cell_type": "markdown",
298+
"metadata": {},
299+
"source": [
300+
"---\n",
301+
"## One Final Check\n",
302+
"\n",
303+
"Run the cell below. If you see a green success message, you are ready to start Chapter 1."
304+
]
305+
},
306+
{
307+
"cell_type": "code",
308+
"execution_count": null,
309+
"metadata": {},
310+
"outputs": [],
311+
"source": [
312+
"print(\"=\" * 40)\n",
313+
"print(\" Notebook is working correctly!\")\n",
314+
"print(\" You are ready for Chapter 1.\")\n",
315+
"print(\"=\" * 40)"
316+
]
317+
},
318+
{
319+
"cell_type": "markdown",
320+
"metadata": {},
321+
"source": [
322+
"---\n",
323+
"**Chapter 0 complete.** Move on to Chapter 1 — Setup & Your First Program."
324+
]
325+
}
326+
],
327+
"metadata": {
328+
"kernelspec": {
329+
"display_name": "Python 3",
330+
"language": "python",
331+
"name": "python3"
332+
},
333+
"language_info": {
334+
"name": "python",
335+
"version": "3.10.0"
336+
}
337+
},
338+
"nbformat": 4,
339+
"nbformat_minor": 4
340+
}

0 commit comments

Comments
 (0)